[an error occurred while processing this directive]

Features of Servlets 2.4

                         

In this tutorial you will learn the new features added in Servlet 2.4.

  1. Upgraded supports for Http, J2SE, and J2EE: Servlet 2.4 depends on Http1.1 and J2SE 1.3.
  2. Additional ServletRequest methods : In Servlet 2.4 four new methods are added in the ServletRequest
    • getRemotePort(): It returns the IP source port of the client.
    • getLocalName(): It returns the host name on which the request was recieved.
    • getLocalAddr(): It returns the IP address on which the request was recieved. 
    • getLocalPort(): It returns the IP port number.
  3. New Support for Internationalization and charset choice: To provide support of internationization, Servlet 2.4 has added two new methods in the ServletResponse interface.
    • setCharacterEncoding(String encoding): The purpose of this method is to set the response's character encoding.  This method helps us to pass a charset parameter to setContentType(String) or passing a Locale to setLocale(Locale). We can now avoid setting the charset in the setContentType("text/html;charset=UTF-8") as setCharacterEncoding() method pairs with the pre-existing getCharacterEncoding() method to manipulate and view the response's character encoding.
       
    • getContentType(): It is responsible for returning the response's content type. The content type can be dynamically set with a combination of setContentType(), setLocale(), and setCharacterEncoding() calls, and the method getContentType() provides a way to view the generated type string. 
  4. New features has been added in RequestDispatcher: In Servlet 2.4 five new request attributes has been added for providing extra information during a RequestDispatcher forward() call. This features has been added is Servlet 2.4 to know the true original request URI. The following request attributes are:
    • javax.servlet.forward.request_uri
    • javax.servlet.forward.context_path
    • javax.servlet.forward.servlet_path
    • javax.servlet.forward.path_info
    • javax.servlet.forward.query_string

  5. SingleThreadModel interface has been deprecated: In Servlet 2.4 the SingleThreadModel interface has been deprecated. 
  6. HttpSession details and interaction with logins has been clarified: The new method HttpSession.logout() has been added in Servlet 2.4. Now session allows zero or negative values in the <session-timeout> element to indicate sessions should never time out. 
    If the object in the session can't be serialize in a distributed environment then it must throw an IllegalArgumentException. 
  7. Welcome file behavior and Classloading has been clarified: In servlet 2.4 welcome file can be a servlet. 
  8. The web.xml file now uses XML Schema: Version 2.4 servers must still accept the 2.2 and 2.3 deployment descriptor formats, but all new elements are solely specified in Schema.

 

                         

[an error occurred while processing this directive]