You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Antonio Si <An...@oracle.com> on 2000/08/16 02:29:39 UTC

servlet multithreading problem ...

Hi,

I have a servlet, CLASSA, which instantiate a singleton object
in the init() method. In the doGet() method, it access
the singleton object. The singleton object perform some
tasks based on an input parameter, event, and write the result
to the HttpServletResponse object.

I also have an HTML file with a Frameset definition as
follows:

<FRAMESET>
  <FRAME SRC = "/servlet/CLASSA?event=A", NAME=A>
  <FRAME SRC = "/servlet/CLASSA?event=B", NAME=B>
</FRAMESET>

If my servlet implements SingleThreadModel, the output is
fine, meaning the frame A and frame B got their
content properly. However, if the servlet does not implement
SingleThreadModel, the two frames got mixed up. Sometimes,
both frames will get content from "event=A", while sometimes,
both frames will get otherwise.

My singleton object only uses local variables. I am also only
using the http listener of tomcat only, i.e., apache is not
set up. I am not sure if that will make any difference.

Any pointer and suggestion to this problem would be highly
appreciated.

Thanks.

Antonio.
========

Re: servlet multithreading problem ...

Posted by "Swords and Ploughshares, Ltd." <ca...@harbornet.com>.
Have you syncronized your threads?
----- Original Message ----- 
From: Antonio Si <An...@oracle.com>
To: <ge...@jakarta.apache.org>
Sent: Tuesday, August 15, 2000 5:29 PM
Subject: servlet multithreading problem ...


> Hi,
> 
> I have a servlet, CLASSA, which instantiate a singleton object
> in the init() method. In the doGet() method, it access
> the singleton object. The singleton object perform some
> tasks based on an input parameter, event, and write the result
> to the HttpServletResponse object.
> 
> I also have an HTML file with a Frameset definition as
> follows:
> 
> <FRAMESET>
>   <FRAME SRC = "/servlet/CLASSA?event=A", NAME=A>
>   <FRAME SRC = "/servlet/CLASSA?event=B", NAME=B>
> </FRAMESET>
> 
> If my servlet implements SingleThreadModel, the output is
> fine, meaning the frame A and frame B got their
> content properly. However, if the servlet does not implement
> SingleThreadModel, the two frames got mixed up. Sometimes,
> both frames will get content from "event=A", while sometimes,
> both frames will get otherwise.
> 
> My singleton object only uses local variables. I am also only
> using the http listener of tomcat only, i.e., apache is not
> set up. I am not sure if that will make any difference.
> 
> Any pointer and suggestion to this problem would be highly
> appreciated.
> 
> Thanks.
> 
> Antonio.
> ========
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
> 
>