2.<%@ page session="true" contentType="text/html; charset=UTF-8"%>
3.<%@ page session="true" contentType="text/html; charset=UTF-8" pageEncoding=""UTF-8%>
If they are different .could someone explain?
<%@ page contentType="text/html; charset=UTF-8"%> are same.
Character encoding can be subset of Content type. For example:
<%@ page pageEncoding="UTF-8"%> are same.
If you use contentType, you may not need to use characterEncoding! Please check the ServletResponse API
public void setCharacterEncoding(java.lang.String charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by setContentType(java.lang.String) or setLocale(java.util.Locale), this method overrides it. Calling setContentType(java.lang.String) with the String of text/html and calling this method with the String of UTF-8 is equivalent with calling setContentType with the String of text/html; charset=UTF-8.
This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.
Containers must communicate the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the character encoding is communicated as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.
charset - a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)