S Ramakrishnan wrote:

> Thanks for your note.
>
> web.xml for my application has clearly
> bound a set of <init-parm>'s with a servlet
> class. Hence the container must be able to
> uniquely determine the set of initial parameters,
> given a servlet class file, regardless of by what name
> ("default" or otherwise) the servlet is invoked.
> Then why should I specify a servlet mapping?
>

The reasoning on why this is necessary goes like this:

* Servlet initialization parameters are defined for a particular
  servlet *definition*, not a particular servlet class.  It is entirely
  legal to have more than one <servlet> definition that uses
  the same class, but they will see different init parameters.

* In order for the container to know which servlet definition
  to use for selecting the servlet to be loaded, it matches
  the request URI against the available <servlet-mapping>
  entries.  Without any mappings, no such servlet definition
  will ever be selected.

* Some servlet containers let you invoke "anonymous" servlets
  by using a request URI of "/servlet/{classname}.  However, this
  feature is *not* defined in the servlet spec, and is *not* portable.


It sounds like you might do better with an alternative strategy:

* Use context initialization parameters instead.

* Name your context initialization parameters with names that
  begin with the classname of a servlet.

* Use the getServletContext().getInitParameter() method
  to read these parameters.

>
> Is this spelt out in the spec? I did not find this in
> Ch13 of the 2.3 draft (I'm using Tomcat 4.0).
>

The particulars discussed above are in Chapters 2, 3, and 11.  Be sure that you
pay attention to all of the spec's requirements, not just the deployment
descriptor.

>
> Rk
> x77309
>

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to