Emma,

If you are declaring variables within the jsp you need to be careful how you are doing it. If for example you declare a variable within the code blocks <%!        String s = "whatever"; %>

This variable has global application scope for that jsp. Any changes in other methods would have to be synchronized or you are not thread safe.

However, if you declare a variable within a jsp within code blocks

<%  String s = "whatever"; %> then you need not worry about synchronization as this variable is declared within the service method of the jsp ( doGet, doPost) and each individual call to the jsp creates a new thread for the service method.

Craig

>Dear All,
>
>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?
>
>Emma
>
>To change your membership options, refer to:
>http://www.sys-con.com/java/list.cfm


Chat with friends online, try MSN Messenger: Click Here
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to