InfoCenter Home >
3: Migration overview >
3.3: Migrating APIs and specifications >
3.3.2: Migrating to supported Servlet specification and extensions

3.3.2: Migrating to supported Servlet specification and extensions

Servlets will require migration if they are not of the supported specification level (2.1) or they rely on deprecated or removed IBM servlet extensions.

See article 3.3.2a for migration considerations for WebSphere Application Server Version 3.5.2.

Migrating to the supported Servlet specification

Refer to the Java Servlet API 2.1 specification for complete information concerning new and deprecated APIs. This table highlights a few of the new and deprecated classes and methods.

Recall, IBM WebSphere Application Server supported the Servlet 2.1 Specification; if you already migrated servlets to 2.1 for use with that release, no further action is required.

Article 4.2.1.2.1a describes the new Servlet 2.2 APIs.

Method or Class Status and recommendation
RequestDispatcher New. Use the forward method to forward a servlet response from one servlet to a second servlet for further processing. Use the include method to include part of the one servlet's response in the body of another servlet's response.

Refer to the code example.

HttpSessionContext Deprecated.
HttpSession.getSessionContext Deprecated. For security reasons, no equivalent.
HttpSession.getMaxInactiveInterval New. Sets the maximum time a session will be maintained by the servlet engine without a client request.
ServletRequest.getRealPath Deprecated. Use ServletContext.getRealPath.
ServletContext.getServlet Deprecated. Use ServletContext.getRequestDispatcher.
ServletContext.getResource New. Use this method to obtain a servlet resource by requesting its URL.
ServletContext.getResourceAsStream New. Use this method to obtain a servlet resource (as an InputStream) from its servlet context.
encodeUrl and encodeRedirectUrl methods of HttpServletResponse Deprecated. But the fix is easy. Change Url to URL in the method names.
HttpSession.isRequestedSessionIdFromUrl Deprecated. Another easy fix. Change Url to URL in the method name.
HttpServiceRequest.setAttribute() Deprecated. See Migrating to supported JSP specification for details.
HttpServiceResponse.callPage() Deprecated. Refer to the code example.

Migrating IBM extensions to the Servlet API

The following packages were are part of the Application Server Version 2.0x, but were removed or deprecated as of Version 3.

Method or Class Status and recommendation
com.ibm.servlet.personalization.sam() Removed -- no recommended replacement
com.ibm.servlet.servlets.personalization.util Removed -- no recommended replacement
com.ibm.servlet.connmgr Deprecated. Starting with Version 3.0x, IBM WebSphere Application Server has provided a built-in connection pooling function that eliminates the need for servlet programmers to use the connection manager APIs directly. Instead, servlets can be written to use the JDBC APIs to access the connection pool.

You are encouraged to migrate servlets that use the deprecated connection manager APIs. See the Related information for details.

Go to previous article: Migrating to supported EJB specification Go to next article: Example: Migrating HttpServiceResponse.callPage()

 

 
Go to previous article: Migrating to supported EJB specification Go to next article: Example: Migrating HttpServiceResponse.callPage()