This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt 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 Introducing JavaFX 8 Programming this week in the JavaFX forum!
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: 42958
    
  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
 
It's not a secret anymore!