Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Servlet Mapping help

 
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser 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
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
MyEclipse IDE Firefox Browser 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
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
MyEclipse IDE Firefox Browser 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.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic