tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 4362] - Reading init-params from a JSP should not need a servlet-mapping
Date Wed, 31 Oct 2001 17:14:28 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4362>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4362

Reading init-params from a JSP should not need a servlet-mapping





------- Additional Comments From craig.mcclanahan@sun.com  2001-10-31 09:14 -------
Remy's analysis of how init parameters work is correct.  To put it in more
general terms:

* <init-param> is a sub-element of <servlet>.  Therefore,
  initialization parameters belong to the particular servlet
  *definition* that is defined by that <servlet> element.

* Initialization parameter names and values are exposed
  (via the ServletConfig) object to any instance of that
  particular servlet definition that is exectued.  (Note
  that it's legal to have more than one <servlet>
  definition with the same servlet class -- the two
  definitions are unique.

* It is legal to have zero or more <servlet-mapping> rules
  that map requests to a particular <servlet> definition.

* The servlet container uses <servlet-mapping> rules to
  select which servlet definition should process a
  request.  Based on this selection, it follows the
  servlet lifecycle rules (single instance of the servlet
  class, call init() before the first request, and son on)
  and passes a ServletConfig object that corresponds to
  the <servlet> definition on to that servlet.

In the absence of a <servlet> definition for a specific page, Tomcat uses a
"*.jsp" URL pattern in a <servlet-mapping> to map them to the default
JspServlet.  Therefore, every page mapped this way should see the init params
for the standard JspServlet.  But note that this is a consequence of the way
that Tomcat happens to implement JSP -- you cannot count on it generally.

The bottom line of all of this -- if you want to utilize servlet initialization
parameters, you *must* define them in a <servlet> definition, and you *must*
provide a <servlet-mapping> that selects that servlet definition.

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message