File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 42276
    
  64
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to hide servlet path?