Re: Java Code Inside Page Directive



vunet.us@xxxxxxxxx wrote :
Hello,
I want to use somE Java code inside of my page directive for JSP page
such as:

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

XXXXX_JAVA_CODE_HERE_XXXXX should be some string I set dynamically:
public static String = "UTF-8";

Please, recommend a solution. Thanks.

You cannot. A directive is for the compiler and is not processed during runtime.

You can however use response.setCharacterEncoding("UTF-8")

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.html#setCharacterEncoding(java.lang.String)

--
Wojtek :-)


.



Relevant Pages

  • Re: Separating design from code - help a Perl monger - java noob
    ... >>you forward to a JSP that does the display. ... Keep the java code out of the ... The forward is accomplished inside the servlet / JSP ... You might also consider custom tags, either via one of the available tag ...
    (comp.lang.java.programmer)
  • Need the path of Jsp that runs on websphere startup
    ... I need to run some java code when websphere starts up the server. ... I've modified web.xml to load my jsp file on ...
    (comp.lang.java.programmer)
  • Re: Syntax checker
    ... designed a JSP Page as an UI for the user to enter formulas. ... price = 20. ... do to retreive and convert to java code, ... Doing this would require writing a full blown compiler. ...
    (comp.lang.java.help)
  • Re: unable to compile class for JSP..
    ... org.apache.jasper.JasperException: Unable to compile class for JSP: ... I haven't changed A THING in this respect, have also not changed Tomcat ... "The generated java code and the class file for this Servlet are stored ... time I loaded this same JSP a few days ago... ...
    (comp.lang.java.help)
  • Re: Book for learning ASP.NET
    ... I worked with ASP for three years before. ... have been working with JSP and Java. ... Can anybody recommend me a right book to learn ASP.NET? ...
    (microsoft.public.dotnet.general)