package org.apache.jsp; import java.util.*; import java.text.*; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import org.apache.jasper.runtime.*; public class codeset1$jsp extends HttpJspBase { static { } public codeset1$jsp( ) { } private static boolean _jspx_inited = false; public final void _jspx_init() throws org.apache.jasper.runtime.JspException { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; String _value = null; try { if (_jspx_inited == false) { synchronized (this) { if (_jspx_inited == false) { _jspx_init(); _jspx_inited = true; } } } _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(0,0);to=(2,0)] out.write("\r\n\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(2,47);to=(3,0)] out.write("\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(3,30);to=(4,0)] out.write("\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(4,30);to=(5,0)] out.write("\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(5,30);to=(110,0)] out.write("\r\n\r\n
\r\n \r\n \r\nThis page under construction, use at your own risk.
\r\nMaking JSP pages that use a Unicode encoding is really easy. You only need to do a\r\n few things to be successful.
\r\nFor starters, you need to understand what happens when you make a JSP page. JSPs are\r\n really Java programs. The JSP container reads the source file and writes a little\r\n Java program that extends Servlet. Click here to see the source\r\n generated for this page. Basically, as the program does is write a byte stream\r\n back to the browser using an OutputStreamWriter.
\r\nInternally, all Java String objects are Unicode UTF-16. So you are working with\r\n Unicode within the JSP page, regardless of the encoding. What you need to do to \r\n have a working page is:
\r\nHere's the code you need to do that.
\r\nFirst, we need to read any input using the right encoding. This requires that you instruct\r\n the ServletRequest object what encoding to use before you read any\r\n data from it. Once you read data from the Request, the encoding is set forever.
\r\nrequest.setCharacterEncoding(\"UTF-8\");
\r\nIf all of your pages use UTF-8, then you can skip the above step. Be careful too of pages that link\r\n to yours but which are not part of your application. If an external page links to you with a form and\r\n it doesn't use UTF-8, you'll null strings when you ask for parameters (since the UTF-8 conversion will\r\n silently fail).
\r\nNext we need to tell the system what encoding the page is written in. This is not necessarily\r\n the same thing as the encoding the page will be in when you serve it, as this directive tells\r\n the JSP system how to read the bytes in the .JSP file. You may find that it is easier to use\r\n a legacy (non-Unicode) encoding to author your pages, since many IDEs and editors don't support\r\n UTF-8 or make it difficult to work with.
\r\nThe pageEncoding directive controls this encoding:
\r\n<%@page pageEncoding=\"UTF-8\"%>
\r\nFinally, we need to control the encoding that the page uses when it is sent to the browser.\r\n This has several parts to it, since you need to set things in several places. First, you\r\n should include a META tag in your HTML markup so that end users can see it. The other\r\n things we are doing to the page are more than adequate to make the page work correctly, but\r\n end users can sometimes debug page display problems (such as when they manually override the\r\n encoding and get junk) by looking at the tag. Here's what a META tag looks like:
\r\n\r\n<html>
\r\n<head>
\r\n <META http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\r\n
Then you need to tell the page compiler what encoding you want to use. This has several\r\n effects. First, it sets the actual encoding used. Second it sets the HTTP Content-Type\r\n header.
\r\n<%@page contentType=\"text/html;charset=UTF-8\"%>
\r\nNote that XML files are handled similarly. XML doesn't use a META tag, but you can\r\n (and should) set the encoding attribute in the document declaration:
\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>
\r\nThere are some caveats about setting the encoding explicitly to UTF-8 using the\r\n contentType page directive. The big one is: prior to J2EE 1.4 (Servlet 2.4), the\r\n JSTL and other taglib directives related to getting and setting the page Locale\r\n caused the page to change encoding to one inferred by the Locale. In J2EE 1.4, this\r\n is fixed (so that the page directive takes precedence over any implicit encoding), but\r\n for now you need to be careful of setting the page Locale. We'll examine that on another\r\n page.
\r\n\r\nNo Charset Specified: Demonstrates how not\r\nusing the page directives results in a page that uses Latin-1.
\r\nInferred Charset: Demonstrates how an inferred character\r\nencoding (from response.setLocale() in this case) overrides the contentType page directive\r\non Servlet 2.3 and earlier. Note that using any of the fmt tags in JSTL in your page will\r\ngive you this same result.
\r\nIncludes: Demonstrates the tags <%@include>\r\nand <jsp:include />.
\r\n\r\nProves that this page really isn't just an ASCII file that happens to work. Note that\r\nif you see hollow boxes for characters that are displable (i.e. not control characters or\r\nunassigned values), then you may need to install a font and/or configure your browser to display\r\nthe text. The stylesheet specifies Arial Unicode MS and Code2000, some common Unicode fonts,\r\nbut you might not have these installed.
\r\n\r\n\r\n\r\n");
out.print(c);
out.print("
");
schar = "0000" + Integer.toHexString(c);
schar = schar.substring(schar.length()-4);
schar = "U+" + schar;
out.print(schar);
out.println("
\r\n Developing Multilingual Web Applications Using JavaServer Pages Technology: the\r\n excellent article by Norbert Lindenberg
\r\nAuthoring Techniques for XHTML and HTML Internationalization: the\r\n primer from the W3C Internationalization WG.
\r\n\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(161,85);to=(162,0)] out.write("\r\n"); // end // HTML // begin [file="/jsp/codesetDemo/codeset1.jsp";from=(162,78);to=(171,0)] out.write("\r\n