[EMAIL PROTECTED] wrote:
> I have a question regarding servlets and frames. I have a single servlet
> that handles HTTP requests.
> Each frame calls this servlet and passes a parameter such as header,
> tableofcontents, mainpage,etc.
> The servlet in turn calls the appropriate function to either display a
> header for the header frame, table of
> contents for that frame,etc,etc. The problem I'm running into is that when
> the framed page loads, sometimes
> the incorrect HTML will be displayed. For instance, sometimes the header
> shows up in the header frame
> as well as the main frame. Is this because I'm calling the same servlet or
> is this a potential bug in JRun?
> Any ideas? suggestions?
>
The most likely cause is that you are using instance variables in your servlet
class to pass information between methods. In an environment like this
(framed presentation with every frame calling the same servlet), it is
extremely likely that multiple requests to your servlet will be happening at
exactly the same time. The servlet engine is multithreaded, so it calls your
service() method on several threads simultaneously.
You need to ensure that you pass information back and forth only by using
method parameters or local variables, or that you add the declaration
"implements SingleThreadModel" to your servlet. This tells the servlet engine
to NOT call your servlet more than once at the same time.
A review of the basic concepts of programming in a multithreaded environment
might also be helpful if this idea is new to you. One good place to start is
the Java Language Tutorial on JavaSoft's web site (http://java.sun.com).
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html