Servlets are share by ALL clients, so the first request in gets the if,
every other request gets the else!

The way around this is to use a session for each client, and store the flag
in the session,

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Narayanaswamy, Kumaran
> (CTS)
> Sent: 18 September 2000 04:57
> To: [EMAIL PROTECTED]
> Subject: Code to be executed once
>
>
> Hi
> My Problem is as follows
> I have a part of Code which should be excuted only for the first
> request,so
> Iam having a flag called firstTime which i had declared at
> <%! boolean firsttime = false %>
> and in the tag <% if(!firsttime) {
>                      firsttime = true;
>                  execute the code only once for first request
>                 } else {
>
>                 }%>
> The code works fine for the first clients request but when Second Client
> request comes it directly goes to the else part wheareas first time it
> should go to the if part and then later requests should take him
> to the else
> part.
> How to do this???
> Thanks
>
>
> with regards,
> Kumaran
> ________________________________________________
> Cognizant Technology Solutions India Ltd,
> 1st Floor ,T.S.140 No 2 & 9,
> C.P.T Road .Taramani
> Chennai - 600 113.
> Phone(0ff): 044 - 2354281/2354411 Extn: 4443
> EMail : [EMAIL PROTECTED]
> _________________________________________________
>
>
>
>
>
>
> This e-mail and any files transmitted with it are for the sole
> use of the intended recipient(s) and may contain confidential and
> privileged information.
> If you are not the intended recipient, please contact the sender
> by reply e-mail and destroy all copies of the original message.
> Any unauthorised review, use, disclosure, dissemination,
> forwarding, printing or copying of this email or any action taken
> in reliance on this e-mail is strictly
> prohibited and may be unlawful.
>
>                 Visit us at http://www.cognizant.com
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to