On Wed, 26 Dec 2001 [EMAIL PROTECTED] wrote:
> Date: Wed, 26 Dec 2001 12:09:12 -0500
> From: [EMAIL PROTECTED]
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: RE: Clarification needed, please
>
>
>
> -----Original Message-----
> From: Randy Layman [mailto:[EMAIL PROTECTED]]
> <snip>
>
> > -----Original Message-----
> > From: Nikola Milutinovic [mailto:[EMAIL PROTECTED]]
>
> <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.
>
Not really. *Servlets* are not scoped -- only attributes (i.e. beans).
> 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.
>
You don't have it quite right. Servlet instance lifecycle information is
defined in Section 2 of the Servlet 2.3 specification, which doesn't have
anything to do with scopes.
Scopes (in the JSP vocabulary) match up to servlet concepts like this:
* "application scope" beans == ServletContext attributes
* "session scope" beans == HttpSession attributes
* "request scope" beans == ServletRequest attributes
* "page scope" beans do not have a direct analog in the Servlet API --
but they act more like local variables in the doGet() or doPost()
method than anything else.
> That's kinda how I've been understanding it. Please correct me if I'm
> wrong.
>
> -Mark
>
Craig McClanahan
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>