Deprecated Jakarta Servlet classes and methods have been removed

Deprecated Jakarta Servlet methods and classes have been removed in Jakarta Servlet 6.0. Remove the usage of these classes and methods from your application.

Removed Jakarta Servlet Classes:

Removed Jakarta Servlet Classes

Replacement Jakarta Servlet Classes

jakarta.servlet.http.HttpSessionContext

None. The jakarta.servlet.http.HttpSessionContext class was removed for security reasons with no replacement.

jakarta.servlet.http.HttpUtils

This class was deprecated. Methods on the request interfaces provide similar functionality. HttpServletRequest.getRequestURL() can replace the functionality of HttpUtils.getRequestURL(HttpServletRequest) and HttpServletRequest.getParameterMap() can replace the functionality of HttpUtils.parsePostData(int, ServletInputStream)​ or HttpUtils.parseQueryString(String)​.

jakarta.servlet.SingleThreadModel

None

Removed Jakarta Servlet Methods:

Removed Jakarta Servlet Methods

Replacement Jakarta Servlet Methods

jakarta.servlet.http.HttpServletRequest.isRequestedSessionIdFromUrl() and jakarta.servlet.http.HttpServletRequestWrapper.isRequestedSessionIdFromUrl()

HttpServletRequest.isRequestedSessionIdFromURL() and HttpServletRequestWrapper.isRequestedSessionIdFromURL()

jakarta.servlet.http.HttpServletResponse.encodeUrl(String) and jakarta.servlet.http.HttpServletResponseWrapper.encodeUrl(String)

HttpServletResponse.encodeURL(String) and HttpServletResponseWrapper.encodeURL(String)

jakarta.servlet.http.HttpServletResponse.encodeRedirectUrl(String) and jakarta.servlet.http.HttpServletResponseWrapper.encodeRedirectUrl(String)

HttpServletResponse.encodeRedirectURL(String) and HttpServletResponseWrapper.encodeRedirectURL(String)

jakarta.servlet.http.HttpServletResponse.setStatus(int, String) and jakarta.servlet.http.HttpServletResponseWrapper.setStatus(int, String)

To set a status code use setStatus(int). To send an error with a description use sendError(int, String).

jakarta.servlet.http.HttpSession.getSessionContext()

None

jakarta.servlet.http.HttpSession.getValue(String)

HttpSession.getAttribute(String)

jakarta.servlet.http.HttpSession.getValueNames()

HttpSession.getAttributeNames()

jakarta.servlet.http.HttpSession.putValue(String, Object)

HttpSession.setAttribute(String, Object)

jakarta.servlet.http.HttpSession.removeValue(String)

HttpSession.removeAttribute(String)

jakarta.servlet.ServletContext.getServlet(String)

None. Previously this method always returned null.

jakarta.servlet.ServletContext.getServlets()

None. Previously this method always returned an empty enumeration.

jakarta.servlet.ServletContext.getServletNames()

None. Previously this method always returned an empty enumeration.

jakarta.servlet.ServletContext.log(Exception, String)

ServletContext.log(String, Throwable)

jakarta.servlet.ServletRequest.getRealPath(String) and jakarta.servlet.ServletRequestWrapper.getRealPath(String)

ServletContext.getRealPath(String)

jakarta.servlet.UnavailableException.getServlet()

None

Removed Jakarta Servlet Constructors:

Removed Jakarta Servlet Constructors

Replacement Jakarta Servlet Constructors

jakarta.servlet.UnavailableException(int, jakarta.servlet.Servlet, String)

UnavailableException(String, int)

jakarta.servlet.UnavailableException(jakarta.servlet.Servlet, String)

UnavailableException(String)

This rule has an automated fix to replace the deprecated Jakarta Servlet classes and methods with their corresponding replacement. Copy the custom configuration to your application build file to enable the fix automation.

For more Jakarta 10 migration information, see Differences between Jakarta Servlet 6.0 and 5.0.

For more information, see the deprecation notes in the Servlet 5.0 Javadoc.