Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Java Code Inside Page Directive

Thread view: 
vunet.us@gmail.com - 31 Jul 2007 19:06 GMT
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.
Wojtek - 31 Jul 2007 19:18 GMT
vunet.us@gmail.com wrote :
> Hello,
> I want to use somE Java code inside of my page directive for JSP page
[quoted text clipped - 6 lines]
>
> 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#setChar
acterEncoding(java.lang.String
)

Signature

Wojtek :-)

vunet.us@gmail.com - 31 Jul 2007 19:31 GMT
> You can however use response.setCharacterEncoding("UTF-8")
>
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.h...)

Can I use response.setCharacterEncoding("utf-8"); on a JSP page?
Wojtek - 31 Jul 2007 19:36 GMT
vunet.us@gmail.com wrote :

>> You can however use response.setCharacterEncoding("UTF-8")
>>
>> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletResponse.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."

Signature

Wojtek :-)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.