Because you declared your boolean inside <%! %> tags, its scope is the
servlet instance, not the request.
If you use <% %> tags, it will be a local variable, but then it's not
exactly clear how this should work. It will of course always be the first
time then.
Maybe you mean that the code should be executed once for every user (and not
request). In that case, store a Boolean in the session.
Geert Van Damme
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Narayanaswamy, Kumaran
> (CTS)
> Sent: donderdag 14 september 2000 13:53
> 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