Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call servlet before each jsp request

 
bhavin pandya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic