jsr340-experts@servlet-spec.java.net

[jsr340-experts] About SERVLET_SPEC_35

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Wed, 25 Jul 2012 15:41:28 -0700

I am looking at issue http://java.net/jira/browse/SERVLET_SPEC-35 ,
"Clarification on section 4.4 Servlet Context Configuration Methods".

Servlet 3.0:
----------
In 4.4 (p.30), we have:
If the ServletContext passed to the ServletContextListener’s
contextInitialized method was neither declared in web.xml or web-
fragment.xml nor annotated with @WebListener then an
UnsupportedOperationException MUST be thrown for all the methods defined
for programmatic configuration of servlets, filters and listeners.

In javadoc of ServletContext of the following method
#getEffectiveMajorVersion
#getEffectiveMinorVersion
#setInitParameter
#addServlet(String, String), #addServlet(String, Servlet),
#addServlet(String, Class<? extends Servlet>)
#createServlet(Class<T>)
#getServletRegistration
#getServletRegistrations
#addFilter(String, String), #addFilter(String, Filter),
#addFilter(String, Class<? extends Filter>)
#createFilter(Class<T>)
#getFilterRegistration
#getFilterRegistrations
#getSessionCookieConfig
#setSessionTrackingModes
#getDefaultSessionTrackingModes
#getEffectiveSessionTrackingModes
#addListener(String), #addListener(T), #addListener(Class<? extends
EventListener>)
#createListener(Class<T>)
#getJspConfigDescriptor
#getClassLoader
#declareRoles
they have the following:
Throws:
UnsupportedOperationException - if this ServletContext was passed to the
ServletContextListener#contextInitialized method of a
ServletContextListener that was neither declared in web.xml or
web-fragment.xml, nor annotated with WebListener

-----

The above seems to be related to blocking ServletContextListeners
declared in TLD to access the 3.0 programmatic API as discussed in jsr
315 expert group with emails title - "Special treatment of
ServletContextListeners declared in TLD resources of web fragments
excluded from absolute ordering".

The 3.0 javadoc seems to be more general compared with those mentioned
in the email.
We should clarify this.

Shing Wai Chan