1

I have a form I want the form(localhost/myapp) which has 3 pages.

1.Input taken From user(asd.jsp)

2.Validation(with the help of DB)(dfg.jsp)

3.To enter Details required for my app.(zxc.jsp)

Now in the url at any given time I want onlylocalhost/myapp/ and I don't want to my jsp filenames on the url..

P.S: Already tried

<servlet>
<servlet-name>myapp</servlet-name>
<jsp-file>/dfg.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>myapp</servlet-name>
<url-pattern>/myapp</url-pattern> 
</servlet-mapping>

its workin but I can still access by the file by Typing the url url..I don't want anyone to do that....So require Guidance!!!

Thanks in Adv!!!

user3300851
  • 87
  • 1
  • 3
  • 12
  • do u send each requests to the servlet? – Santhosh Mar 03 '14 at 09:36
  • @sankrish I didn't cause it did not my criteria(constant URL name) so stopped after the first one. – user3300851 Mar 03 '14 at 09:50
  • This will be going to solve your doubt – jmail Mar 03 '14 at 09:57
  • if u want to generate a dynamic URL , you can go for URL rewriting . So that the users can't access the pages through their URL. – Santhosh Mar 03 '14 at 10:01
  • ofcourse your jsp will be accessible with file name. To prevent it you can use filter and map it with url *.jsp that is any url ending with .jsp. If it find such url it should give an error like 404 or some custom error message you want. – Ravi Kumar Mar 03 '14 at 13:00

1 Answers1

0

Put the jsp under WEB-INF. Then it will not be accessible by filename in the url. You obviously will have to change your web.xml accordingly:

<servlet>
<servlet-name>myapp</servlet-name>
<jsp-file>/WEB-INF/dfg.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>myapp</servlet-name>
<url-pattern>/myapp</url-pattern> 
</servlet-mapping>
developerwjk
  • 8,619
  • 2
  • 17
  • 33
  • I did not get you.i have 4 jsp files and do u want me to move all the jsp files to WEB-INF from WebContent? – user3300851 Mar 04 '14 at 03:48
  • If you want to map them to a URL like (sever/appname/somemappedname) but for them to not be accessibly normally (server/appname/file.jsp), then that's what you have to do to. – developerwjk Mar 10 '14 at 20:22
  • For those you are OK with them being accessed normally, you don't need to move them. For those you need to be accessed normally, you should not move them, because once you put them in WEB-INF they cannot be accessed normally. Anything under WEB-INF can only be accessed if its mapped. – developerwjk Mar 10 '14 at 20:24