On Mon, 3 Dec 2001, Ing. Gabriel Gajdos wrote:
> Date: Mon, 3 Dec 2001 09:41:39 +0100
> From: Ing. Gabriel Gajdos <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: RE2: Jsp compile option for Big5 encoding / encoding question
>
> Craig (or somebody else), could you, please, give me a hint in following question?
>
> | JSP pages follow these rules:
> |
> | * If you declare a "pageEncoding" attribute on your <%@ page %>
> | directive (supported in JSP 1.2 only), that character set is used
> | to read the text of the page itself (as the page is being compiled).
> |
> | * The character encoding from the contentType attribute of the
> | <%@ page %> directive is used, if present
>
> I know and use these settings...
> But:
> Is it possible to have SINGLE JSP page with *variable* encoding/Content Type?
>
> <%@ page contentType="text/html; charset=XY" %>
>
> And I want to set the Content Type (or charset/encoding) according to *current*
>conditions.
> For example acording to a field value from database, or Property from .properties
>file with language dependent settings.
>
> Is this possible in T4? IMHO JSP specifications do not say about this.
>
> I would like to make something similar (this syntax is NOT correct):
>
> <%@ page contentType="p.getProperty("ContentType")" %>
>
> I also tried a custom tag solution, but with no success.
> It seams, directives bitween <%@ %> directives can not contain executable code.
>
> Of course, this approach works when using servlet (I mean variable ContentType).
> So can this also be done in JSPs?
> Or in this case is the only way to do it by using Unicode?
>
> Thanx in advance.
>
In JSP 1.1 you cannot reliably do this. In JSP 1.2, the container is
required to allow you to set the content type and character encoding
dynamically, either like this:
<%
String contentType = "text/html;charset=Big5"; // Or whatever
response.setContentType(contentType);
%>
or by having a custom tag do this for you. The only restriction is that
you have to set this before the output buffer is flushed.
> GG
>
Craig
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>