aspose file tools*
The moose likes Servlets and the fly likes How to call servlet before each jsp request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to call servlet before each jsp request" Watch "How to call servlet before each jsp request" New topic
Author

How to call servlet before each jsp request

bhavin pandya
Greenhorn

Joined: Jan 21, 2006
Posts: 2
Hello Friends,

What I want to do is before request goes to any of my jsp i want to call one servlet.

I am planning to check cache in that intermediate servlet ..
if the requested jsp is already cached then that servlet only print the content from cached file.
otherwise it will make url call to the requested jsp in background and will generate the cache file also.
so that it can be useful for next request.

One way to do this is ,... changing the url like this.

Existing URL: http://myserver.com/application/jspname.jsp&id=userid
New URL: http://myserver.com/application/myservlet?page=jspname&id=userid

but for this I need to change path in my whole application.

Isnt it possible through any configuration changes ?

Please suggest me some other way...

Thanks in advance.
Bhavin Pandya
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
Originally posted by bhavin pandya:
Hello Friends,

What I want to do is before request goes to any of my jsp i want to call one servlet.

I am planning to check cache in that intermediate servlet ..
if the requested jsp is already cached then that servlet only print the content from cached file.
otherwise it will make url call to the requested jsp in background and will generate the cache file also.
so that it can be useful for next request.

One way to do this is ,... changing the url like this.

Existing URL: http://myserver.com/application/jspname.jsp&id=userid
New URL: http://myserver.com/application/myservlet?page=jspname&id=userid

but for this I need to change path in my whole application.

Isnt it possible through any configuration changes ?

Please suggest me some other way...

Thanks in advance.
Bhavin Pandya



Sounds more like a Filter to me. Why not register a Filter in your web.xml? You can even tailor it to be applied only to certain URLs that way.


%
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to call servlet before each jsp request
 
Similar Threads
Could someone try and explain
how do I know what the user has clicked?
tomcat4.1 : relative and absolute paths
jsp:include page="header.html" causes IllegalStateException
jsp:include page="header.html" causes IllegalStateException