• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Mapping help

 
gowtham potter
Greenhorn
Posts: 27
Firefox Browser MyEclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Firefox Browser MyEclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Firefox Browser MyEclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic