aspose file tools*
The moose likes Servlets and the fly likes Servlet Mapping help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Mapping help" Watch "Servlet Mapping help" New topic
Author

Servlet Mapping help

gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

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


hai visit my website http://hacktohell.blogspot.com
for tech tips & tricks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

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().


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

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

Joined: Jan 10, 2002
Posts: 61010
    
  65

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

Joined: Nov 02, 2010
Posts: 27

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Mapping help