Think about how each of the 2 declarations will be scoped in the servlet
that gets generated by the JSP compilation.
<%! %> variables will be scoped as data members of the Servlet object.
Remember that Servlet engines typically instantiate only one instance of
a servlet object that is shared by all threads that are processing a
request for that servlet. This means that these variables are shared by
several threads of execution and thread safety must be considered when
accessing or changing these variable's values.
<% %> variables will be scoped as local to the generated doGet or doPost
functions. There will be one of these variables instantiated for each
thread that is processing a request for that servlet.
- Kevin
Variables declared in <%! %> blocks are shared by all threads
Kevin Guan wrote:
>
> What is the difference between declaring variables in <%! %> and <% %> ?
>
> Geert Van Damme wrote:
>
> > Most important thing:
> > Stay away from <%! tags.
> > I know sometimes you need them, but I've seen people use a lot of these tags
> > when in fact they needed <% %>
> > There are other issues of course, but IMO that's the most important
> > regarding JSP.
> >
> > Geert 'Darling' Van Damme
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification and reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Allen Hillman
> > > Sent: maandag 8 mei 2000 21:53
> > > To: [EMAIL PROTECTED]
> > > Subject: JSP Thread safety
> > >
> > >
> > > Can anyone supply tips to ensure thread safety within a JSP page?
> > >
> > > Specific things to look for, things to do and not do.
> > >
> > > Thanks,
> > >
> > > Allen Hillman
> > >
> > > Software Engineer
> > >
> > > Kana Communications
> > > 50 Phillippe Cote Street
> > > Manchester NH 03101
> > > Voice: 603-665-1382
> > > Fax: 603-665-1982
> > >
> > > ==================================================================
> > > =========
> > > 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
>
> ===========================================================================
> 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