wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servicing *all* requests" Watch "Servicing *all* requests" New topic

Servicing *all* requests

K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375

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.

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

Joined: Mar 22, 2005
Posts: 41049
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.

Ping & DNS - my free Android networking tools app
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375

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
Similar Threads
Tomcat class file problem
trouble with geronimo plugin for eclipse
Tracking a session between Weblogic and ATG
How do we use global variables in servlets?
Voice Mail