This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
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: 41034
    
  43
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.


Ping & DNS - my free Android networking tools app
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to hide servlet path?
 
Similar Threads
can we retrieve cookie with JSP added thru servlet
good servlet/jsp host
New to Weblogic
Context-Root problem in WAS5
The requested resource is not available