This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to hide servlet path? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "How to hide servlet path?" Watch "How to hide servlet path?" New topic
Author

How to hide servlet path?

Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
Hi all,

I have HTML form (JSP file) like below, the UpdateLogin servlet class is mapped in web.xml.

in UpdateLogin servlet, I forward the view to this JSP again, BUT... in the browser it shows http://host/time/servlet/UpdateLogin.do

and if the user hits http://host/time/servlet/UpdateLogin.do directly, it throws NULLPointerException because some parameters are not set.

TIA



SCJP 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
if the user hits http://host/time/servlet/UpdateLogin.do directly, it throws NULLPointerException because some parameters are not set.


The class should check for required parameters, and take appropriate action if some are missing.


Android appsImageJ pluginsJava web charts
Sandeep Deb
Greenhorn

Joined: Jun 01, 2007
Posts: 15
Agree with Ulf. Although you can hide the URL from the user, it's not a good solution. Instead, the recommended way is to harden your servlet to take care of exception conditions.


- <a href="http://www.sandeepdeb.com" target="_blank" rel="nofollow">Sandeep</a>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It could be that your servlet only supports the POST method.
One solution is to implement a doGet method that forwards the user to the page that contains the form.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
Originally posted by Ben Souther:
It could be that your servlet only supports the POST method.
One solution is to implement a doGet method that forwards the user to the page that contains the form.


Thanks to Ulf and Sandeep. But I prefer Ben's idea.

I can check the the input parameters but sounds clumsy in complex form. If I use struts or other frameworks (not sure which ones), do they have build-in mechanism to valdate user input?

thanks again.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to hide servlet path?
 
Similar Threads
Context-Root problem in WAS5
can we retrieve cookie with JSP added thru servlet
New to Weblogic
The requested resource is not available
good servlet/jsp host