if you are only using local variables the method is inherently thread safe
as each thread that executes the mehtod will allocate its own local
varaibles of the heap.

Beware though of your calling parameters. If you pass objects / arrays in
and modify those then there *may* be concurrecy issues, depending on where /
how those objects / arrays were created.

> -----Original Message-----
> From: Emmanuel Eze [SMTP:[EMAIL PROTECTED]]
> Sent: 15 August 2002 09:56
> To:   [EMAIL PROTECTED]
> Subject:      Re: Basic question: repeating code in JSP pages?
>
> Are u saying that I do not need to synchronize my methods so long as I'm
> not
> using instance variables?  What then happens when I call such methods
> concurrently?
>
> -----Original Message-----
> From: Adrian Janssen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 15, 2002 10:40 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Basic question: repeating code in JSP pages?
>
>
> If you are using instance variables, you would need to syncronize. However
> rather try not to use instance variables. As you have pointed out, Java
> can
> only return a single value, but that could be an array or an object
> containing many values, see if that can be used to solve your problem.
>
> Try to avoid syncronisation - it slows things down and is also a rich
> source
> of difficult to fix bugs.
>
> > -----Original Message-----
> > From: Emmanuel Eze [SMTP:[EMAIL PROTECTED]]
> > Sent: 15 August 2002 09:15
> > To:   [EMAIL PROTECTED]
> > Subject:      Re: Basic question: repeating code in JSP pages?
> >
> > Hans wrote:
> > >If you promise to move the code to a servlet/bean/action later, I tell
> > >you how ;-) You can use a JSP declaration to declare a method:
> > >
> > >   <%!
> > >     private String createColumnClause(String column, String value) {
> > >       ...
> > >       return clause;
> > >     }
> > >   %>
> > >
> > >Note that the method has access to only instance variables (which
> should
> > >be avoided for thread-safety reasons) so you have to pass it all data
> > >it need as parameters.
> > >
> > >You can then call it from a scriptlet:
> > >
> > >   <%
> > >     String clause = createColumnClause("email", email);
> > >   %>
> > >
> > >Hope this helps,
> > >Hans
> >
> >
> > Is it necessary to synchronize methods in JSP so as to make them thread
> > safe?  When do I need to synchronize them?  Again, if for instance my
> > method
> > need to return multiple values, in which case I'm forced to use instance
> > variables since Java can only return a value.  How can I make the JSP
> > thread
> > safe?
> >
> >
> ==========================================================================
> > =
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.jsp
> >  http://www.jguru.com/faq/index.jsp
> >  http://www.jspinsider.com
> --
>
> It is the strict policy of Truworths that its e-mail facility and all
> e-mail communications emanating therefrom, should be utilised for
> business purposes only and should conform to high professional and
> business standards.   Truworths has stipulated certain regulations in
> terms whereof strict guidelines relating to the use and content of
> e-mail communications are laid down. The use of the Truworths e-mail
> facility is not permitted for the distribution of chain letters or
> offensive mail of any nature whatsoever.   Truworths hereby distances
> itself from and accepts no liability in respect of the unauthorised
> use of its e-mail facility or the sending of e-mail communications
> for other than strictly business purposes.   Truworths furthermore
> disclaims liability for any  unauthorised instruction for  which
> permission was not granted.    Truworths Limited accepts no liability
> for any consequences arising from or as a result of reliance on this
> message unless it is in respect of bona fide Truworths business for
> which proper authorisation has been granted.
>
> Any recipient of an unacceptable communication, a chain letter or
> offensive material of any nature is requested to notify the Truworths
> e-mail administrator ([EMAIL PROTECTED]) immediately in order that
> appropriate action can be taken against the individual concerned.
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
--

It is the strict policy of Truworths that its e-mail facility and all
e-mail communications emanating therefrom, should be utilised for
business purposes only and should conform to high professional and
business standards.   Truworths has stipulated certain regulations in
terms whereof strict guidelines relating to the use and content of
e-mail communications are laid down. The use of the Truworths e-mail
facility is not permitted for the distribution of chain letters or
offensive mail of any nature whatsoever.   Truworths hereby distances
itself from and accepts no liability in respect of the unauthorised
use of its e-mail facility or the sending of e-mail communications
for other than strictly business purposes.   Truworths furthermore
disclaims liability for any  unauthorised instruction for  which
permission was not granted.    Truworths Limited accepts no liability
for any consequences arising from or as a result of reliance on this
message unless it is in respect of bona fide Truworths business for
which proper authorisation has been granted.

Any recipient of an unacceptable communication, a chain letter or
offensive material of any nature is requested to notify the Truworths
e-mail administrator ([EMAIL PROTECTED]) immediately in order that
appropriate action can be taken against the individual concerned.

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to