This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 41180
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
Consider Paul's rocket mass heater.
subject: Servicing *all* requests
Similar Threads
How do we use global variables in servlets?
Voice Mail
Tomcat class file problem
trouble with geronimo plugin for eclipse
Tracking a session between Weblogic and ATG