InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.1: Developing servlets >
4.2.1.2: Servlet support and environment in WebSphere >
4.2.1.2.1a: Features of Java Servlet API 2.2

4.2.1.2.1a: Features of Java Servlet API 2.2

WebSphere Application Server supports Java Servlet API 2.2 and JSP 1.1.

Java Servlet API 2.2 contains many enhancements intended to make servlets part of a complete application framework

These new functions in the Servlet 2.2 specification are SUPPORTED by WebSphere Application Server:

  • response buffering
  • WAR files (for depoyment)
  • multiple error page support
  • welcome file list
  • new request mapping logic
  • session timeout per Web application
  • session scoping per Web application
  • MIME mapping table per Web application
    (MIME table now exists at the VirtualHost and Web application)
  • request dispatchers by servlet name
  • Request dispatchers by relative path
  • duplicate header support:
    (req.getHeaders(name), resp.addHeader())
  • initialization parameters on a Web application
  • internationalization improvements:
    (getLocale(), getLocales())

The following J2EE extensions in the Servlet 2.2 specification are NOT SUPPORTED:

  • J2EE security
  • roles
  • APIs:   isUserInRole() and getUserPrincipal()
  • J2EE-style Form Login
  • EJB reference
  • resource reference
  • environment entry
  • reference deployment information in web.xml
  • security deployment information in web.xml
  • accessing a JSP file through the URI without the .jsp extension, as for example,
    ../jsp/HitCount
    
  • creating a sevlet and associating a JSP file as the handler for the servlet
       The Servlet 2.2 specification allows you to associate a JSP tag to the servlet tag. However, the WebSphere Application Server WAR conversion tool does not support the <jsp-file> tag. The JSP tag association is illustrated in the following code example:
    <servlet>
    <servlet-name>JSPTest</servlet-name>
    <jsp-file>/jsp/HitCount.jsp</jsp-file>
    </servlet>
    
    /*mapping to URI*/
    <servlet-mapping>
    <servlet-name>JSPTest</servlet-name>
    <url-pattern>/jsp/HitCount.jsp</url-pattern>
    </servlet-mapping>
    

The Servlet 2.2 specification is available at java.sun.com/products/servlet/index.html

No new classes were added to the Java Servlet API 2.2. specification. The following table provides more information on 27 new methods, 2 new constants and 6 deprecated methods supported by WebSphere Application Server:

New methods Description
getServletName() Returns the servlet's registered name
getNamedDispatcher(java.lang.String name) Returns a dispatcher located by resource name
getInitParameter(java.lang.String name) Returns the value for the named context parameter
getInitParameterNames() Returns an enumeration of all the context parameter names
removeAttribute(java.lang.String name) Added for completeness
getLocale() Gets the client's most preferred locale
getLocales() Gets a list of the client's preferred locales as an enumeration of locale objects
isSecure() Returns true if the request was made using a secure channel
getRequestDispatcher(java.lang.String name) Gets a RequestDispatcher using what can be a relative path
setBufferSize(int size) Sets the minimum response buffer size
getBufferSize() Gets the current response buffer size
reset() Empties the response buffer, clears the response headers
isCommitted() Returns true if part of the response has already been sent
flushBuffer() Flushes and commits the response
setLocale(Locale locale) Sets the response locale, including headers and charset
getLocale() Gets the current response locale
UnavailableException(String message) Replaces UnavailableException(Servlet servlet, String message)
UnavailableException(String message, int sec) Replaces UnavailableException( int sec, Servlet servlet, String message)
getHeader(String message) Returns all the values for a given header, as an enumeration of strings
getContextPath() Returns the context path of this request
addHeader(String name, String value) Adds to the response another value for this header name
addDateHeader(String name, long date) Adds to the response another value for this header name
addIntHeader(String name, int value) Adds to the response another value for this header name
getAttribute(String name) ObjectHttpSession.getValue(String name)
getAttributeNames() Replaces String[] HttpSession. getValueNames()
setAttribute(String name, Object value) Replaces void HttpSession.setValue( String name, Object value)
removeAttribute(String name) Replaces void HttpSession.removeValue( String name)
New constants Description
SC_REQUESTED_RANGE_NOT_SATISFIABLE New mnemonic for status code 416
SC_EXPECTATION_FAILED New mnemonic for status code 417
Newly deprecated methods Description
UnavailableException(Servlet servlet, String message) Replaced by UnavailableException( String message)
UnavailableException(int sec, Servlet servlet, String message) Replaced by UnavailableException( string message, int sec)
getValue(String name) Replaced by Object HttpSession.getAttribute(String name)
getValueNames() Replaced by numeration HttpSession.getAttributeNames()
putValue(String message, Object value) Replaced by void HttpSession.setAttribute(String name, Object value)
removeValue(String message) Replaced by void HttpSession removeAttribute(String name)

Go to previous article: Features of Java Servlet API 2.1 Go to next article: IBM extensions to the Servlet API

 

 
Go to previous article: Features of Java Servlet API 2.1 Go to next article: IBM extensions to the Servlet API