Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When the jsp contacts the servlet for the first time in a session

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am having a jsp page which sends a request to the servlet.

(In a session the jsp page contacts this servlet many times )

Is there any way so that to know that this particular request is the first request from the jsp .

Thank you
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are a lot of choices to do it . for example while forwarding use a parameter which can tell the servlet that the request is from the jsp.
based on the parameter you can create a counter.

avi sinha>
 
Shakeel Shaik
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try this approach

First write a listener that implements an HttpSessionListener
Implement the methods sessionCreated and sessionDestroyed, somewhat like this.


In jsp -> <% increment counter %>

In your servlet -> //check counter

hope this helps.
give it a try and let us know how it went.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all . Thank all for you for help .

shaks ss what you said is a complex approach . I would prefer what sinha has mentioned .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shaks ss", please check your private messages for an important administrative matter.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic