<%! String str=""; %>
The above translates into a declaration within the generated servlet class.
By adding this line,
you have created a class variable, instantiated and initialized when the
class is loaded.
If you want to use this one every request, you probably want to do the
following:
<% String str=""; %>
-AMT
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Dennis Huang
> Sent: Tuesday, March 14, 2000 10:30 PM
> To: [EMAIL PROTECTED]
> Subject: Something strange
>
>
> Hi:
>
> I have a piece of code look like this:
>
> <%! String str=""; %>
> <% for (int i=1; i < 10; i++) { str = i +"<br>"+str; } %>
> Before <B>JSP</B> Output <P>
> <%= str %>
> <P> After <B>JSP</B> Output
>
> This works. The strange thing is each time I click on the Refresh, <%=str
> %> outputs more and more repeated values(from 9 to 1). It seems <%! String
> str=""; %> does not work from the second time I click on the
> Refresh button.
> Do you know why? I am using Tomcat and IE5.
>
> Thanks,
>
> Regards,
>
> Dennis Huang
> ___________________________________________________
> DATACOM SYSTEMS
> 34 Waterloo, North Ryde | * 0061-2-9023 5214
> Sydney, NSW 1670 | * 0061-2-9023 5300
> Australia | * [EMAIL PROTECTED]
>
> ==================================================================
> =========
> 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