Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java Code Inside Page Directive

Reply
Thread Tools

Java Code Inside Page Directive

 
 
vunet.us@gmail.com
Guest
Posts: n/a
 
      07-31-2007
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.

 
Reply With Quote
 
 
 
 
Wojtek
Guest
Posts: n/a
 
      07-31-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/ap...va.lang.String)

--
Wojtek


 
Reply With Quote
 
 
 
 
vunet.us@gmail.com
Guest
Posts: n/a
 
      07-31-2007

>
> You can however use response.setCharacterEncoding("UTF-8")
>
> http://java.sun.com/j2ee/1.4/docs/ap...vletResponse.h...)



Can I use response.setCharacterEncoding("utf-8"); on a JSP page?

 
Reply With Quote
 
Wojtek
Guest
Posts: n/a
 
      07-31-2007
(E-Mail Removed) wrote :
>>
>> You can however use response.setCharacterEncoding("UTF-8")
>>
>> http://java.sun.com/j2ee/1.4/docs/ap...vletResponse.h...)

>
>
> Can I use response.setCharacterEncoding("utf-8"); on a JSP page?


Did you read the JavaDoc? It is all explained in there:

"This method can be called repeatedly to change the character encoding.
This method has no effect if it is called after getWriter has been
called or after the response has been committed."

--
Wojtek


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compile directive for conditional compile for Java 1.4 versus Java 5 timjowers Java 7 02-02-2011 12:08 AM
Using-declaration or using-directive inside unnamed-namespace? Niels Dekker - no reply address C++ 1 04-27-2010 04:16 PM
Page properties in the @Page directive Jeff ASP .Net 3 01-17-2007 04:30 PM
Page Directive - New Page Properties Philip ASP .Net Web Controls 0 03-21-2006 03:31 PM
The 'Location' attribute is not supported by the 'OutPutCache' directive????when i set in the directive .NET Follower ASP .Net 1 02-13-2004 10:32 AM



Advertisments