简体   繁体   中英

JSP Page Directive

I have 2 difference page directive codes in my jsp, i don't know what is the difference between contentType , charset , and pageEncoding , i read thruOracle JSP Globalization Support but didn't understand quite well , can anyone explain the difference in simpler way?

<%@ page contentType="text/html;charset=GBK"%>

VERSUS

<%@page contentType="text/html;charset=GBK" pageEncoding="GBK"%>

http://www.satollo.net/jsp-and-the-content-type-charset-and-the-page-encoding-attribute

ContentType charset

The contentType charset is how the servlet container which runs the JSP must send to the browser the text generated by the page.

PageEncoding

The pageEncoding directive is used to correctly read the JSP from the file system. Since even the JSP is a text but a file is a sequence of bytes on disk, it can be correctly read only knowing the charset to use.

Then:

ContentType charset: How the client have to interpret the file

PageEncoding: How to read the jsp from the filesystem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM