> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 26, 2001 12:09 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Clarification needed, please
> 
> 
> 
> 
> 
> <snip>
> 
> > If Tomcat gets two requests, handled by the same servlet, 
> > will the same instance of that servlet handle it?
> Yes.  Tomcat will always create exactly one instance of a servlet
> for each unique URL that can access it (i.e. two servlet mappings 
> equals two instances).
> 
> Doesn't this depend upon how the servlet is scoped?  Tomcat 
> will compile one
> jsp per *.jsp file but instantiates the servlet differently 
> according to the
> servlet's scope being either application, session, or request.
> 
> Randy is explaining application scope.  You get one instance 
> of the servlet
> and state is maintained across all accesses.
> 
> Session scope will maintain state for the duration of an http 
> session and
> request scope will give you a new servlet for each request 
> with no memory
> shared (and no shared memory) between requests.
> 
> From what I understand of the Servlet Spec. a servlet must be 
> contained
> within one instance of a JVM (because of concurrency issues) 
> but, that is
> not related to the servlet scope which pertains to the 
> semantics of your web
> application.
> 
> That's kinda how I've been understanding it.  Please correct me if I'm
> wrong.

        I just reread all the passages of the Servlet specification that use
the word scope and cannot find a single reference to servlet scoping.  The
only scope I know of related to web applications would be data - and that is
where the application, session, page, and request scopes are defined.  The
scoped data is maintained in other classes (for example HttpServletRequest
for request scope and HttpSession for session scope) and have no relation to
the servlet's internal data structures (i.e. static and class variables).

        That is how I read the spec, and that is how I have found Tomcat to
work.

        Randy

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to