Encoding in jsp

I am Using
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" > for encoding charset. It accepts [insert and retrieval] all german and french characters except � (alt+0128) ..
And also i tried
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> in JSP. It only helps to retrieve the � data. When i saved that euro sign,it stored as a junky character
Any ideas please help me

Thanks for your reply.
I achieved this issue through the steps given below
1) In JSP
<%@ page pageEncoding="utf-8" %> <%@ page language="java" contentType="text/html;charset=utf-8" %>
<meta http-equiv=content-type content="text/html; charset=utf-8">
2) In web.xml,
<!DOCTYPE web-app
a) PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
b) <filter>
<filter-name>SetCharacterEncodingFilter</filter-name>
<filter-class>mypackage.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
Note: filter tag must be top of the servlet tag

Similar Messages

  • Hi, how to use URL encoding in jsp

    hi, how to apply URL encoding in jsp for a string, could u pls suggest some ideas to use URL encoding in jsp
    thank you in advance

    hi, thnx for the reply, but my problem is to use url encoding method
    i would u like to know how to represent in jsp program i have asp code some thing like this
    href='/project/tel_number.asp?team=<%=DbRecTeam("id")%>&name=<%=Server.URLEncode(DbRec("name"))%>'
    i would like to know how replace that Server.URLEncode stmt in jsp, could u pls suggest some equivalent method for the above stmt
    thanx in advance

  • Character encoding in JSP

    hi all.
    my problem is about character encoding in JSP.
    my project is based on struts framework & mysql database. as a servlet container i have the Tomcat absolutely.
    i have correctly set the mysql db. when i insert data by hand, usin' INSERT INTO bla bla, it works with Turkish Characters.
    After that, i have checked, my jsp page correctly loads data from db and displays on browser. all the special Turkish characters appears well.
    The problem starts with posting!
    I want some data from the user, and i have simple wysiwyg javascript editor. the editor correctly process the text, after posting data and saving into db, some how it corrupts.
    (whatever, i have tried it with a simple textarea, it does not work)
    simply my problem is: the data somehow corrupts while it is being posted.
    thanx.

    on the form processing page, you probably need to call request.setCharacterEncoding("UTF-8") (or whatever encoding you're using) before reading any values.
    Reply #14 of this post has some test page with Chinese which should work as is...
    http://forum.java.sun.com/thread.jspa?forumID=513&threadID=546863

  • Character Encoding for JSPs and HTML forms

    After having read loads of postings on character encoding problems I'm still puzzled about the following problem:
    I have an instance (A) of WL 8.1 SP3 on a WinXP machine and another instance (B) of WL 8.1 without any SP on a Win2K machine. The underlying Windows locale is english(US) in both cases.
    The same application deployed as a war file to these instances does not behave in the same way when it comes to displaying non-Latin1-characters like the Euro symbol: Whereas (A) shows and accepts these characters as request-parameters, (B) does not.
    Since the war file is the same (weblogic.xml, jsps and everything), the reason for this must either be the service-pack-level or some other configuration setting I overlooked.
    Any hints are appreciated!

    Try this:
    Prefrences -> Content -> Fonts & Color -> Advanced
    At the bottom, choose your Encoding.

  • Over-riding Character encoding in JSP

    I have JSP which was precompiled under weblogic with no encoding.I want to change the encoding during run time using response or request Object.I am using filters before JSP's so the response encoding is not getting to JSP even though i try to set in the response by
              response.setContentType("text/html;SJIS") it is getting lost.So i tried to set in the request as an attribute and retreived in the JSP page directive.It did not work.
              The browser is not detecting my character encoding why?.Is there anything called static encoding from weblogic that is causing problem?.If it is, how would I turn off the static encoding from the weblogic programmatically in JSP so that browser detects correct encoding in the page directive dynamically.I even tried
              request.setCharacterEncoding("SJIS") which is japenese but it did not work.Any help would be appreciated.The encoding it shows in the browser by default is "UTF-8" even i though i send "SJIS" encoding in the request

    on the form processing page, you probably need to call request.setCharacterEncoding("UTF-8") (or whatever encoding you're using) before reading any values.
    Reply #14 of this post has some test page with Chinese which should work as is...
    http://forum.java.sun.com/thread.jspa?forumID=513&threadID=546863

  • Encoding issues JSP

    Hi,
              we have an application running on Resin. We are migrating to weblogic and I noticed that there is a default encoding set for the request / response (ISO encoding). Is there a way this can be defaulted to the application's encoding type. I need this because our encoding type can be dynamically changed by the user, and we are using request / response.setContentType() in our servlet to handle the encoding. I dont want weblogic to override my settings. Can someone advise on this?
              Regards
              Parthiban

    There maybe 2 possible options I can think of for this requirement,
              1. use "locale-encoding-mapping-list" in web.xml to map adjust the encoding for your locale.
              2. configure your weblogic.xml, specify "encoding" property in "jsp-descriptor" or "charset-params" and have a try. Since I don't know the exact version of your WLS, you can visit the following edoc links to get what you want
              http://e-docs.bea.com/wls/docs81/webapp/weblogic_xml.html,
              http://e-docs.bea.com/wls/docs90/webapp/weblogic_xml.html,
              http://e-docs.bea.com/wls/docs100/webapp/weblogic_xml.html
              Thanks,
              -Fred.

  • URLencoded UTF string returns in wrong encoding from JSP

    I have hit behavior that makes me rather unhappy and nothing in docs...
    1/ I fetch string in UTF-8, OK
    2/ I URLencode it, OK
    3/ I click on the link with data from steps 1/,2/, OK
    4/ I get the data and siplay it, encoding is wrong
    I'm running Tomcat4 and this ehaviour is a bit annoying.
    Please, if you know, what I can do with it, tell me, I read the
    some docs but found nothing.
    Thanks

    Encoding is wrong? Use the servlet's getEncoding() method to find out what encoding it used. There is no setEncoding() method until level 2.3 of the servlet specification, and your system is likely not using that. But there may be somewhere in the Tomcat configuration where you can specify the default encoding it should use.

  • HTML Encoding in JSP

    I want to display the output in a JSP page as per the data entered in a form in another JSP page.
    I am able to do this; however, if HTML tags are used, then I want them to be treated as literals.
    Further, I want to preserve the line spaces/new lines while displaying the output. By default, the browser justs treats the output as HTML.
    Pls. advise.

    I want to display the output in a JSP page as per the
    data entered in a form in another JSP page.
    I am able to do this; however, if HTML tags are used,
    then I want them to be treated as literals. You will have to search the string for < and replace them with &gt;. Or, if you are using JSTL, you can use:
    <c:out value="${theString}" excapeXml="true"/>
    >
    Further, I want to preserve the line spaces/new lines
    while displaying the output. By default, the browser
    justs treats the output as HTML.Put <pre></pre> tags around the output.
    >
    Pls. advise.

  • UTF-8 encoded JSPs compilation problem

    Hi,
              I'm using Weblogic 9.0 Beta. I have an XML-format UTF-8 encoded JSP (with the proper encoding declarations). I can see that this is compiled into a UTF-8 Java servlet by WebLogic.
              At the compilation to a class file though, the encoding is corrupted. I guess that the Java compiler is assuming a system-encoded (which would be ISO-8859-1) Java file instead of the actual UTF-8 encoding.
              This problem did not occur with WebLogic 8.1.
              I have tried to explicitly tell the Java compiler to treat the source files as UTF-8 in weblogic.xml, i.e.
              <jsp-param>
              <param-name>compileFlags</param-name>
              <param-value>-encoding UTF8</param-value>
              </jsp-param>
              but that had no effect.
              Anyone else noticed this?
              I assume that correct behaviour is for WebLogic to preserve encoding from JSP to servlet to class file, rather than for me to set encoding in weblogic.xml. Is that correct?
              Is there a workaround?
              Thanks for any help you can offer!

    Solved
    It is about Tomcat's character encoding not about the codes..
    For more info:
    [http://wiki.apache.org/tomcat/Tomcat/UTF-8]

  • JSP transfer-encoding: other that chunked?

    Is it somehow possible not to use the chunked transfer encoding in JSP pages? I am using Tomcat 4.0.3 and there seems to be problems with Java Web Start and the chunked encoding.. (see my other topic "Chunked encoding")..

    I found the workaround that I was looking for:
    I added the argument allowChunking="false" to the Tomcat configuration file.
    The actual bug that causes the problem is most propably in JRE 1.3..

  • UTF-8 encoding not working in MSIE

    We're in the process of migrating to Sun Web Server 6.1 2005Q4 SP5 from iPlanet 4.1. The Unicode encoding in JSPs for special characters rendered correctly in browsers with iPlanet 4.1. But in 6.1, I had to add this directive to obj.conf for it to work in Netscape 8 (Firefox engine):
    ObjectType fn="set-default-type" charset="utf-8"However, MSIE still doesn't render the special characters correctly.
    I tried the suggestions in http://swforum.sun.com/jive/thread.jspa?forumID=16&threadID=48171
    and I tried this:
    ObjectType fn="match-browser" browser="*MSIE*" set-srvhdrs="Content-type: text/html;charset=utf-8"with no success.
    Any ideas?
    Thanks!

    1) Here's a sample snippet from the JSP:
                    items.add(new DisclaimerInfo("\342\200\240", "The award is2) Here's the first few lines of the page in the browser's View Source:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />3) Here's the interesting part of obj.conf:
    <Object name="default">
    AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"
    NameTrans fn="DynamoNormalizeURL"
    NameTrans fn="DynamoPath" path="/messaging"
    NameTrans fn="ntrans-j2ee" name="j2ee"
    NameTrans fn="pfx2dir" from="/mc-icons" dir="/app/sunone/ns-icons" name="es-internal"
    NameTrans fn="pfx2dir" from="/SearchServer" dir="/www/site/content/search/SearchServer/wwwtemplates"
    NameTrans fn="pfx2dir" from="/Scripts" dir="/www/site/cgi-bin" name="cgi"
    NameTrans fn="pfx2dir" from="/cgi-bin" dir="/www/site/cgi-bin" name="cgi"
    NameTrans fn="document-root" root="$docroot"
    PathCheck fn="unix-uri-clean"
    PathCheck fn="check-acl" acl="default"
    PathCheck fn="find-pathinfo"
    PathCheck fn="find-index" index-names="index.jsp,index.html"
    ObjectType fn="set-default-type" charset="utf-8"
    ObjectType fn="type-by-extension"
    ObjectType fn="force-type" type="text/plain"
    Service fn="DynamoService" method="(GET|HEAD|POST)" type="dynamo-internal/*"
    Service method="(GET|HEAD)" type="magnus-internal/imagemap" fn="imagemap"
    Service method="(GET|HEAD)" type="magnus-internal/directory" fn="index-common"
    Service method="TRACE" fn="service-trace"
    Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file"
    Error fn="error-j2ee"
    Error fn="send-error" reason="Not Found" path="/www/site/content/error/404.html"
    Error fn="send-error" reason="Server Error" path="/www/site/content/error/servererror.html"
    AddLog fn="flex-log" name="access" iponly="1"
    </Object>4) In MSIE, the snippet from the JSP renders as:
    <small letter A with circumflex><Euro sign> The award is...
    5) Instead, it should render as (which it does in Netscape/Firefox):
    <cross> The award is...

  • Problems using GET method in JSP

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET method in JSP?
    If anyone have solutions, please let me know.
    thanks.

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in
    windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is
    good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET
    method in JSP?
    If anyone have solutions, please let me know.
    thanks.This problem appears, when one use UTF-16 encoding in JSP - am I right?
    If so there are two solutions:
    1) Temporary: Use "UTF-8" - or any other 8 bit encoding scheme and
    encode Korean symbols with "&1234;" kind of escapes - though it
    may not work
    2) Absolute: get my piece of code, which I have managed to write
    just a month ago resolving absolutely similar problem with UTF-16
    in code using Chinese/Russian/English encodings
    But I wouldn't say that it's costs 10 DDs :) - it's much more
    expensive... So try 1st variant if it wouldn't help - let me know.
    I'll figure :)
    Paul

  • Japanese charcters displaying as "?" on a JSP page

    Hi
    My database is UTF-8. I am loading some japaneese data using sql*loader and using Java.IO mechanism(Reader classes). Both ways it is storing the data on database in proper(Japanese) format. If I print it on dos-prompt then same Japanese characters are printing, no problem till here. But if I try to print the same data in database on a JSP page then it is printing "?"(question marks). Also, if I insert any data from a JSP page then it is inserting it as "?" on database. Any help, I really appreciate that.
    Thanks
    Ram

    I am using Chinese Windows NT 4.0
    I succeed in displaying Big5 chinese using Unicode encoding in JSP.
    Now I encounter problem in displaying HK fonts.
    Nevertheless,
    Have your tried to set the charset in your jsp file ?
    <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
    Or have tried to set the browser encoding method to your desired one shift-jfs
    <% response.setContentType("text/html; charset=UTF8");%>
    Lastly, have you tried including a parameter in your getBytes stream
    String temp = rs.getString("headline");
    String newResult = new String(temp.getBytes("UTF-8"),"UTF-8");
    Hope this is related!

  • Arabic jsp problem

    Hi All
    I have problem with arabic encoding in jsp
    here is my problem
    I have jsp page and contains textfield
    user put some text and submit the page
    this text is compared with other text that read from text file
    if two texts are equal some message appears to user
    I have made sample project it works fin with English text
    but it fails with Arabic texts
    her is my sample code
    <%
        String txt=request.getParameter("txt");
        if(txt!=null){
           if(MyClass.test(txt)){
               out.println("values are equal");
           }else{
               out.println("values are not equal");
        %>and method test is static method from MyClass
    public static  boolean test(String x) throws FileNotFoundException, IOException{
            LineNumberReader reader=new LineNumberReader(new FileReader("c:\\test.txt"));
            String line=reader.readLine();
            return line.equals(x);
        }I have tried HTML metaTage with Arabic encoding -notworked-
    and also tried <%@page with Arabic encoding also not worked
    any help will be
    appreciated
    thanks

    You use a Reader without specifying an encoding there. So you are using the system's default encoding. Most likely this is an encoding that does not match the actual encoding of that file which contains Arabic characters.
    Change your code to use an InputStreamReader and specify the correct encoding.

  • Japanese Charecter Encoding

    Hi,
    My application is currently using the following configuration
    1..Weblogic Server 7.0 (running on Windows Machine with Japanese OS)
    2..JDK 1.3
    I am retriving some data from the database in my JSP(say JSP1).Some of this data
    is in Japanese.Now I form a URL using some of the Japanese Data and forward it to the
    next jsp(say JSP2).
    The Japanese data retrived in JSP1 appears fine on the Browse screen.However when in JSP2
    I try to get these paranmeters(in Japanese) from the request (i.e. request.getParameter(..)), they come up
    in mangled form.
    All the JSPs of my applications include the following page directive:-
    <%@page contentType="text/html; charset=Shift_JIS"%>
    Please help

    Hey,
    Thanks a lot for the help,it worked ( and sorry for the delay in the response).
    In the second jsp (JSP B), I have the following code
    request.setCharacterEncoding("Shift_JIS");
    strFile = request.getParameter("FileType");
    Although the code seem to be working I am not very clear about this logic please could you explain me the following points :-
    1..Why was there a specific need to setCharacterEncoding(), I had already set <%@page contentType="text/html; charset=Shift_JIS"%>
    in both the jsps, doesn't that imply that the response encoding and the request decoding be done using 'Shift_JIS'
    2..The same initial code (without addition of the line - request.setCharacterEncoding("Shift_JIS")) worked on my colleagues PC(he was NOT accessing my server though).How was that possible, are there any specific browser/server level setting which be set to default?
    3..In Internet Explorer,if you GO to 'Tools' -> 'Internet Options' -> 'Advanced' Tab ,there is an option ' Always send URLs as UTF-8' .
    What is the significance of this setting ?
    4..How would the browser encoding setting(under 'View' -> 'Encoding') , effect jsps, which are using a specific encoding?
    Thanking you in Anticipation

Maybe you are looking for