• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Mapping help

 
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello i want to map a servlet that runs for all the url supplied to it eg:-
if the reg url is example.com/anything

Then a servlet must be invoked

I tried in servlet mapping in web.xml /*
but it is not working, i get MalFormedUrl Exception!

Also how do i read the anything(example.com/[anything])
Must i use getServletPath() or get it from getRequestUrl()??
Thanks in Advance,
Regards,
Gowtham Potter
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mapping /* is a bad idea because that means that your servlet will be responsible for serving everything, including images, stylesheets, script files and so on. Is that really what you want to get into?

What's wrong with /prefix/*, where "prefix" is something meaningful? That's a lot easier to deal with.

Within the servlet, you can obtain the remainder of the trailing info on the URL with getPathInfo().
 
gowtham potter
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok i accept what you suggest with the prefix/*
But will mapping it get me the desired results?


Thanks for getPathInfo()!!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gowtham potter wrote:But will mapping it get me the desired results?


The desired result of getting all URLs routed to the servlet? No. But I don't think that's really what you want? Is it? Really?
 
gowtham potter
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay fine I will tell you what i want to do with it!

I was trying to keep it secret but........

I am trying to write a proxy in Google App engine!

I already wrote one HackToHell proxy.

But i used the HTTP Post method to post to /learning and get the webpage,
Now I want the ability to do this

if they go to hacktohell-proxy.appspot.com/go/google.com then it must go to google.(using HTTP get method)

That is why I was asking about the servlet mapping!
So how do I map this (I tried and deployed some 80 times but none worked{do not ask me what i did , i did all sorts of stupid things and proably nowhere close to the actual answer})?
I believe this answers your question

Thank YOU,
Regards,
Gowtham.
reply
    Bookmark Topic Watch Topic
  • New Topic