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 Servicing *all* requests Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servicing *all* requests" Watch "Servicing *all* requests" New topic
Author

Servicing *all* requests

K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Hello,

Can I prevent clients from directly reaching a web resource (such as a JSP file) via its path name on the server? In such an event, I want it to go through my "controller" servlet so that I can do some checking before the server submits its response.

Thanks.
[ October 26, 2005: Message edited by: K Riaz ]
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
The controller parameter can set a request parameter (say, controller=true). In the JSP, you check for the presence of that parameter. If it's absent, you redirect to an appropriate page. This check should live in its own JSP page page, which you include in any page that's not supposed to be directly accessible.
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Thanks.

Problem solved by adding a mapping to all *.jsp extensions to my controller servlet, which does the checking. Works perfectly.
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
Filter is a better alternative


Sarath Mohan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servicing *all* requests