• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to hide servlet path?

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sandeep Deb
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic