O'Meara AnnMarie wrote:

> I'm confused about what I've heard about internationalization with JSPs.  What I
> want to do is write one JSP file, and read the character set and user-visible
> text from a ResourceBundle.  This works with HTML templates, as long as the
> .properties files for the ResourceBundles are in the right codepage.  (The HTML
> markup is in ASCII, no matter what character set the user-visible text uses.)
>
> But what I'm hearing on the one hand is that the JSP itself has to be compiled
> with the same character set or codepage as the user-visible text.  That would
> mean that I would have to compile the JSP several times, once for each character
> set.  Is this correct?

The JSP is compiled with the same character set as the text in the JSP.  That's not
necessarily the same as the user-visible text.  In your case, the JSP is compiled
with just the HTML tags.

Because you're reading the i18n text at runtime, it doesn't matter what the
JSP encoding is.

>
>
> The other, conflicting thing I have heard is that you don't have to recompile
> the JSP, but that you do have to create a special "out" writer (using Java
> embedded in the JSP) and tell it what character set or codepage to use.  Is this
> correct?

Yes.  More accurately, you just need to set response.setContentType:

<%@ page language=java contentType="text/html; charset=utf8" %>
<%
  String encoding = "EUC_KR";
  response.setContentType("text/html; charset=" + encoding);
%>
<html><body>
<p><%= grabSomei18nText() %>
...
</body></html>

In this case, the JSP page is parsed as utf8, but printed in EUC_KR.  The JSP only
needs to be compiled once.

Scott Ferguson
Caucho Technology

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to