Dear Craig,

  That means, there is no way to get the virtual path
of current project. Instead, conf/server.xml or
WEB_INF/web.xml should be read so as to get the path
configuration.

  if project APPLE, define a docBase /APPLE/
  I should do some hard coding in web.xml like  
<web-app>
  <servlet-mapping>
    <servlet-name>
      programMain
    </servlet-name>
    <url-pattern>
      /program/*
    </url-pattern>
  </servlet-mapping>

  <servlet>
   <servlet-name>Index</servlet-name>
   <servlet-class>programMain</servlet-class>
   <init-param>
      <param-name>path</param-name>
      <param-value>/APPLE/program/</param-value>
   </init-param>
  </servlet>  
</web-app>

if I want to change docBase from APPLE to ORANGE, then
I should also change
<param-value>/APPLE/program/</param-value> to
<param-value>/ORANGE/program/</param-value>

It is not adaptable when docBase path change.

Thx.

M.T.


--- "Craig R. McClanahan" <[EMAIL PROTECTED]> wrote:
> 
> 
> On Mon, 6 Aug 2001, Diu Lee Lo Mo wrote:
> 
> > Dear Craig,
> >  
> >    Is that the servlet instance will be created
> once a
> > request is coming in ? The target class will call
> > init() when it is called at first time ? 
> > 
> 
> That is correct.  See the servlet spec for more
> details:
> 
>   http://java.sun.com/products/servlet/download.html
> 
> >    My whole picture is :
> >    request -> target class -> init() 
> > 
> 
> Almost, but not quite, complete.  The way I think of
> it is:
> 
>   request --> servlet definition --> init() if
> needed --> service()
> 
> The differences from your picture:
> 
> * Which servlet definition is selected is based on
> the various
>   <servlet-mapping> elements in your web.xml file. 
> See the rules
>   in the servlet spec for how this is determined.
> 
> * There will be an instance of a servlet
> *per-servlet-definition*
>   (i.e. per <servlet> element in your web.xml file),
> unless your
>   servlet implements SingleThreadModel -- in which
> case the container
>   might create more than one instance.  (Tomcat
> doesn't do this.)
> 
> * The very first time a particular <servlet>
> definition is accessed,
>   the instance will be created and init() will be
> called.  Alternatively,
>   you can declare a <load-on-startup> element inside
> the <servlet>
>   definition to cause the servlet to be loaded when
> the web application
>   is first started.  This is quite handy when the
> initialization process
>   is time consuming, because you can make it happen
> before the first
>   request to the servlet.
> 
> * For each request (including the first), service()
> will be called.
> 
> * Tomcat supports a non-spec-defined (but very
> common) feature called
>   the "invoker", where you can execute a URL that
> includes
>   "/servlet/{classname}".  In essence, Tomcat
> creates a <servlet>
>   definition on the fly the first time this is
> encountered, and the
>   rest of the rules defined above are applied.
> 
> >    Thx.
> > 
> > M.T.
> > 
> 
> Craig
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to