Wayne wrote:
>> I have a JSP that has a StringBuffer that is appended to 30 times and
>> at the end it is converted to a string with sb.toString(). The
>> problem I have with two almost instantanious executions of the JSP the
>> contents of the StringBuffer are mixed. I thought that StringBuffer
>> was thread safe. Any suggestions would help.
> Well, content is mixed - but in a thread safe manner. :-)
>
[quoted text clipped - 3 lines]
> *concurrently*). You need to change it from an instance variable to a
> local variable (i.e. created for every execution).
Even better, don't declare StringBuffers in JSPs at all. There is danger in
having to much Java scriptlet in a JSP; some would say none is the maximum.
(Marty Hall, author of / Core Servlets & JavaServer Pages/, is an infamous
excoriator of scriptlet in JSP.)
- Lew
Daniel Pitts - 14 Feb 2007 22:52 GMT
> Wayne wrote:
> >> I have a JSP that has a StringBuffer that is appended to 30 times and
[quoted text clipped - 17 lines]
>
> - Lew
Where I work (won't name names, but its a large media company), our
"legacy" JSPs have too much Java mixed in.
We are moving away from our legacy system, and our newer webapps don't
allow ANY java in JSPs. For the record, we use Spring MVC.