Forums Register Login

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

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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>
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 .
+Pie Number of slices to send: Send
"shaks ss", please check your private messages for an important administrative matter.
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1503 times.
Similar Threads
Can I use Servlet Session in JSP Page.
How is java code in jsp executed in first request ?
UseBean, scope question.
Servlet
Do I understand scope, redirects and JSPs correctly?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 21:46:05.