| Author |
When the jsp contacts the servlet for the first time in a session
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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
|
Save India From Corruption - Anna Hazare.
|
 |
avi sinha
Ranch Hand
Joined: Mar 15, 2009
Posts: 452
|
|
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>
|
SCJP 5.0 SCWCD 5.0
|
 |
Shakeel Shaik
Greenhorn
Joined: Jan 28, 2009
Posts: 5
|
|
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
Joined: Apr 18, 2009
Posts: 2234
|
|
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
Joined: Jan 10, 2002
Posts: 56529
|
|
|
"shaks ss", please check your private messages for an important administrative matter.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: When the jsp contacts the servlet for the first time in a session
|
|
|