French characters in a JSP page

I have an HTML page with a form that has a text field that can accept text from the user. This text can be multilanguage and when French charcters are in the text field, when the user submits the HTML form, my JSP that retrieves the text from the text field is not encoding the characters properly.
For example, this line:
�nonc� sur la sant�, la s�curit� et le milieu de travail
Into a String object in my JSP page as this:
�?nonc�� sur la sant��, la s��curit�� et le milieu de travail
This is no doubt an encoding problem but I am not sure hot to fix it.
Anyone have any recommendations?

That indeed helped.
I had this page directive in the JSP page that contained the form:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>But I needed to add this line to the JSP page that the form was being posted to:
request.setCharacterEncoding( "UTF-8" );

Similar Messages

  • Writing UTF-8 characters to a JSP page (URGENT).

    Hello everybody!
    I am trying to write UTF8 encoded characters to a jsp page, but is seems as if the PrinterWriter I get back in the getWriter call keep returning a writer parametrized for the ISO-8859-1 character set.
    I am calling setContentType with "text/html; charset=UTF-8" as parameter but it does not help.
    Anyone know what I should do?
    Thanx alot!
    Regards Daniel

    I put the following in a "page" directive at the top of my JSPs:
    contentType="text/html; charset=UTF-8"
    That handles getting a jspWriter that write UTF-8.
    You also need to convert the parameters you get from the browser's form input fields to UTF-8 encoded Strings.
    Like this:
    String temp = req.getParameter(parmName);
      // bail out if nothing here
      if (temp ==null) return "";
      try
        temp  = new String(temp.getBytes("ISO-8859-1"),"UTF-8");
      catch (Exception e)
        Mydebug("UTF-8 conversion exception");
      }When you get the parameter it is UTF-8 encoded, but Java's default encoding is ISO-8859-1. After executing the conversion above, temp is a UTF-8 encoded String.

  • Unsavory Characters doodling in JSP page

    Hi All,
    I have a jsp page which i precompiled into a servlet using Tomcat.
    When I access the JSP page it displays the Copyright symbol correctly but when i dispose of the JSP page and use the servlet class the following characters are displayed.
    Copyright �?�� 2003-2005.
    Please tell me why this is happening.
    Thanks in advance,
    Phani

    Post the encoding-related statements from your JSPs - there are a number of different ones that may be relevant.
    It may also be relevant which database you store the strings in (Oracle, DB2, etc.), since some require an encoding parameter to be passed.

  • Junk characters like" � � "displayed in the jsp page please help.

    Hi,
    I am getting junk characters like � � displayed in the jsp page.
    In the JSP page i used javascript "& nbsp" for appending spaces to a string "CCR" to get "CCR " .
    Now the Resultant string "CCR " has three spaces appended to its right.
    This String is set in session in that JSP page.
    In the next JSP page i am getting that string from session.
    After getting the string the "substring" function is performed to get only the first 5 charcters of the string. Now the result is displayed as " CCR� � " with has last 2 characters as junk values � � insteed of displaying as "CCR ". Please help me in solving this issue.
    Please note that initially the sting "CCR" is got from the Oracle database in Solaris Machine.
    Regards,
    Vijay

    have you tried:
    strenuously inspecting the string that is coming from the db? do an actual loop over the string, character by character, dumping to System.out to make sure the characters are EXACT coming out of the db.
    note you have to append " " not just "& nbsp"
    post the code that is doing the output. the relevant bean code, the jsp, everything relevant - WITH COMMENTS discussing where things are happening.
    Also, is it "weird characters" in the browser only? have you done a view source on the actual html source that the browser is rendering (right click in IE and click view source). browsers can act odd if you don't feed then exactly what they want, and it looks like you're feeding it escaped characters that it is rendering as something else.

  • Displaying Japanese characters in JSP page

    Hi,
    I am calling an application which returns Japanese characters from my JSP. I am getting the captions in Japanese characters from the application and I am able to display the Japanese captions. After displaying the Japanese captions, user will select the particular captions by selecting the check box against the caption and Press Save button. Then I am storing the captions in the javascript string separated by :: and passing it to another JSP.
    The acton JSP retrieves that string and split it by using tokenizer and store it in the database. When I retrieve it again from the database and display it, I am not able to see the Japanese characters, it is showing some other characters, may be characters encoded by ISO.
    My database is UTF-8 enabled and in my server I am setting the UTF-8 as default encoding. In my JSP pages also, I am setting the charset and encoding type as UTF-8.
    I shall appreciate you if you can help me in resolving the issue.

    Post the encoding-related statements from your JSPs - there are a number of different ones that may be relevant.
    It may also be relevant which database you store the strings in (Oracle, DB2, etc.), since some require an encoding parameter to be passed.

  • Problems with French Characters in Page Title

    Here is the problem
    When using Duplicate Page and trying to set page titles with french characters (or other non standard characters for that matter such as qoutes) The resulting output does not display correctly.
    I thought a work around would be to us the HTML escape codes in the title dialog when creating the page  however it appears that Incontext then goes and attemps to escape the ampersand part of the escape code during save.
    so for instance when trying to set a page title such as Whistler Live! prépare la scène using the following escaped version
    Whistler Live! pr&eacute;pare la sc&egrave;ne
    The resulting HTML saved from incontext looks like this
    Whistler Live! pr&amp;eacute;pare la sc&amp;egrave;ne
    and the title does not display correctly.
    Incontext sees the & which is page of the HTML escape code and they automatically replaces that with &amp;
    How the heck can we set HTML Special characters in our page titles - any ideas?

    Hi Corey
    To answer your questions I am on windows 7 IE 8 and also tried in firefox 3.6
    backend is windows 2000 / IIS 6 / Coldfusion 8
    I am able to enter the characters in the dialog box but during the save they are altered
    I created a basic test page with nothing but the following code
    <!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" xmlns:ice="http://ns.adobe.com/incontextediting">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    </head>
    <body>
    <div ice:editable="*" >
      <p>Test test</p>
    </div>
    </div>
    <script src="/includes/ice/ice.js" type="text/javascript"></script>
    </body>
    </html>
    saved it as test-characters.cfm (coldfusion page) and tested it out
    problem was still there however when I save the page as a .html file and test it out the problem is no longer present
    So the problem seems to only occur when using .cfm pages (even if there is no cf code on them)
    I am going to send you a private message with access to my test pages in case your inclined to take a look
    Thanks for you help so far

  • Special characters are not displaying in ADF jsp page

    Hi All,
    By using ADF view controller,I am getting the data from database table but when I display the data in jsp page after special character < what ever the data is there it is not displaced.Provide any suggestions.
    Thanks in Advance
    Mani

    Hi Mani,
    < is a special HTML character and obviously it may not me displayed correctly.
    Here is a reference of all HTML special characters: http://www.w3schools.com/tags/ref_entities.asp
    In your case you can replace < with its special symbol representation - *&amp;#60; or &amp;lt;*
    I also advice you to do so for all special HTML characters.
    You can use this Java library for that purpose : http://commons.apache.org/lang/api/org/apache/commons/lang3/StringEscapeUtils.html
    Nikolay

  • French characters

    Now I have an application which has both french and english characters.Can some one tell me what setting I must have in my browser,my windows 2000 machine and my developing environment JDeveloper.
    The reason why I am asking it is I am having problem displaying some characters in my browser,JDeveloper debugging window etc,even though the data exist in the database.In short when I say
    //note assume xx is a french character
    Friends the peculiar thing is that after I say
    //assume xx as a french character.
    SELECT NAME,ADDRESS FROM MY_TABLE WHERE NAME LIKE(�%xx%�);
    String s = rs.getString(�NAME�);
    �xx�
    If s.equals(�xx�){
    //do something
    The select statements finds the french characters,if condition finds the french characters but when I print it in JSP it gives some junk ? characters.In short, the database has the french characters in it ,even the variable s has french characters in it but when it comes to display in browser or in a window (while de-bugging in Jdeveloper) it shows junk character.Surprisingly there are only few selected french characters(1 %) having that problem.I mean only 3 or four french characters are having problem in display,other french characters(99% of it) can be displayed properly.Now I cant go on finding out which characters are having problem and go on converting them to its decimal equivalent.It looks like my Windows 2000 machine needs some setting.But I am wondering what
    Please help.

    I don't think it is anything to do with your browser or machine settings. I had a similar problem. I had an application where the user would upload content to another site in a Microsoft Word document. The JSP page would display the '?' character for MS Word specific characters (like smart quotes etc)
    The basic issue is that when you are using JSP pages to display stuff, you are relying on the Java String object and it ends up using the default character set. So you need to read it into a string using the characterset you want, and then display it using the characterset you want.
    For example, I used the code below in my JSP. I read from a file. You may have to customize it for your requirements.
    <%
    String winCharset = "Cp1252";
    FileInputStream fis = new FileInputStream("filename.xxx");
    BufferedReader br = new BufferedReader(new InputStreamReader(fis, winCharset));
    while(true){
      String lineDefault = br.readLine();          
      if(lineDefault == null) {
        break;
      byte[] bytes = lineDef.getBytes(winCharset);
      String lineWin = new String(bytes, winCharset);%>
      <%=lineWin%>               
    <%}          
    br.close();
    %>Hope this helps!
    SP

  • Urgent: SAX parser bean is not working in JSP page

    Hi All,
    I have created a bean "ReadAtts" and included into a jsp file using
    "useBean", It is not working. I tried all possibilities. But Failed Plz Help me.
    Below are the details:
    Java Bean: ReadAtts.java
    package sax;
    import java.io.*;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import java.util.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import javax.xml.parsers.ParserConfigurationException;
    public class ReadAtts extends DefaultHandler implements java.io.Serializable
         private Vector attNames = new Vector(); //Stores all the att names from the XML
         private Vector attValues = new Vector();
         private Vector att = new Vector();
         private Locator locator;
         private static String start="",end="",QueryString="",QString1="",QString2="";
    private static boolean start_collecting=false;
         public ReadAtts()
         public Vector parse(String filename,String xpath) throws Exception
    QueryString=xpath;
         StringTokenizer QueryString_ST = new StringTokenizer(QueryString,"/");
         int stLen = QueryString_ST.countTokens();
         while(QueryString_ST.hasMoreTokens())
              if((QueryString_ST.countTokens())>1)
              QString1 = QueryString_ST.nextToken();
    else if((QueryString_ST.countTokens())>0)
                   QString2 = QueryString_ST.nextToken();
         SAXParserFactory spf =
    SAXParserFactory.newInstance();
    spf.setValidating(false);
    SAXParser saxParser = spf.newSAXParser();
    // create an XML reader
    XMLReader reader = saxParser.getXMLReader();
    FileReader file = new FileReader(filename);
    // set handler
    reader.setContentHandler(this);
    // call parse on an input source
    reader.parse(new InputSource(file));
         att.add("This is now added");
         //return attNames;
    return att;
    public void setDocumentLocator(Locator locator)
    this.locator = locator;
    public void startDocument() {   }
    public void endDocument() {  }
    public void startPrefixMapping(String prefix, String uri) { }
    public void endPrefixMapping(String prefix) {  }
    /** The opening tag of an element. */
    public void startElement(String namespaceURI, String localName,String qName, Attributes atts)
    start=localName;
    if(start.equals(QString2))
    start_collecting=true; //start collecting nodes
    if(start_collecting)
    if((atts.getLength())>0)
    for(int i=0;i<=(atts.getLength()-1);i++)
    attNames.add((String)atts.getLocalName(i));
    attValues.add((String)atts.getValue(i));
    /** The closing tag of an element. */
    public void endElement(String namespaceURI, String localName, String qName)
    end = localName;
    if(end.equals(QString2))
         start_collecting=false; //stop colelcting nodes
    /** Character data. */
    public void characters(char[] ch, int start, int length) { }
    /** Ignorable whitespace character data. */
    public void ignorableWhitespace(char[] ch, int start, int length){ }
    /** Processing Instruction */
    public void processingInstruction(String target, String data) { }
    /** A skipped entity. */
    public void skippedEntity(String name) { }
    public static void main(String[] args)
    String fname=args[0];
    String Xpath=args[1];
    System.out.println("\n from main() "+(new ReadAtts().parse(fname,Xpath)));
    //System.out.println("\n from main() "+new ReadAtts().attNames());
    //System.out.println("\n from main() "+new ReadAtts().attValues());
    JSP File:
    <%@ page import="sax.*,java.io.*,java.util.*,java.lang.*,java.text.*;" %>
    <jsp:useBean id="p" class="sax.ReadAtts"/>
    Data after Parsing is.....
    <%=p.parse"E:/Log.xml","/acq/service/metrics/system/stackUsage")%>
    Expected Output:
    The jsp file should print all the vector objects from the "ReadAtts" bean
    Actual Output:
    Data after Parsing.......[]
    Thanks for your time.....
    Newton
    Bangalore. INDIA

    the problem is not because of java code insdie jsp page
    I have removed all things but the form and it is still not working
    here is the modified code:
    <!-- add news-->
    <%
    if(request.getParameter("addBTN") != null){
            out.print("addBTN");
    %>
    <!-- end of add news-->
    <form action="" method="post" enctype="multipart/form-data" name="upform" >
      <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr>
          <td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
        </tr>
        <tr>
          <td width="87%" align="right"><label>
            <input name="title" type="text" class="rightText" id="title">
          </label></td>
          <td width="13%" align="right">9FH'F 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
              </textarea></td>
          <td align="right">*A'5JD 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input type="file" name="filename" id="filename">
          </label></td>
          <td align="right">5H1)</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input name="addBTN" type="submit" class="btn" id="addBTN" value="  '6'A) .(1 ">
          </label></td>
          <td align="right"> </td>
        </tr>
      </table>
    </form>
    <!-- TinyMCE -->
    <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
            tinyMCE.init({
                    mode : "textareas",
                    theme : "simple",
                    directionality : "rtl"
    </script>
    <!--end of TinyMCE -->

  • Engineering character issue in conversion of jsp page to ms-excel format

    Hi,
    I have a requirement of down loading the jsp page into an ms-excel sheet. for this I am using following code:
    response.setContentType("application/vnd.ms-excel;charset=UTF-8");
    the conversion is fine but the numeric fields whose length exceeds 11 characters is appearing in the engineering format (i.e.,11E+3211). But it should appear as plain number.
    The following are the constraints that I do have:
    1. The version of java in client machine is 1.2.1
    2. I cannot use external jar files like (JExcel, EZJCom or POI)
    So please can you find some feasible solution.

    Reading between the lines, it appears that the issue is that the generated file is referencing a hard coded path to the CSS file. If the client does not actually have the file C:\LTS\CSS\main.css on their system at the time of the request, then the response is logical.
    This is clearly going to create issues with portability (why would an unknown client have the file C:\LTS\CSS\main.css) so unless you are doing this for your singular use, then you need to look at another method of relaying the css data. The most reliable mechanism would be to embed it directly in the generated file inside a <style> tag. You could also serve the css as its own page from your webserver, but it could create problems if the users are saving the generated files and then attempting to use them when disconnected from the network.

  • How to display XML file(as markup) in jsp page..?

    Hi All,
    * I have to display the XML file(as markup) in jsp page (Tree Format)....
    * My XML file is an java.io.file object , and how to view this XML file on my JSP page...........
    Thanks in Advance,
    JavaImran

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • Problem with French characters with updateContent

    I have this problem with Spry, (had it also with YUI a few
    months ago) with special french characters
    (éèçàù). I use encoding UTF-8, but
    iso-8859-1 isn't working either. I put some examples here:
    http://www.eventsonholiday.com/test_loadurl.asp
    As long as it is static content, no problem. But when I get
    content from a recordset from an Access database: trouble.
    In IE7 the french characters are even worse, and I get the
    error: null is empty or not an object

    I think I found a solution. I found a few resources on the
    internet that said: xmlhttprequest always sends data as utf-8 by
    default. So when all the other pages use iso-8859-1, there's a
    problem. It can be solved this way: when retrieving recordset
    fields from ASP I use
    HTMLEncoding like this:
    <%=Server.HTMLEncode(RSevents.Fields.Item("event_location").Value)%>.
    I have to do this for each field in the page, what means some extra
    work.
    For PHP it should be done with
    htmlentities
    If anyone has a solution without using the Server.HTMLEncode
    method, tell me...

  • Euro(�) character in JSP -page

    I'have a JSP-page where is html-textbox for adding salary wish for the job and the problem is that I can't � character from request!
    I have to pages. In first one i have form where the text box is and a second one for saving the info to a bean.
    I have tried to use this tag in JSP pages :
    <%@ page contentType="text/html; charset=windows-1252" %>
    and after this code:
    String salaryWish = request.getParameter("salaryWish");
    System.out.println("Salary wish(�): " + salaryWish);
    String euro = "�";
    System.out.println("euro: " + euro);
    makes this kind of prints to Tomcat 3.2 window
    Salary wish(�): 1233 ?
    euro: �
    and if I print the same to textfile those � characters are actually � characters as they should be. But now the euro mark that I filled to salaryWish textbox and got from request is changed to ?.
    Does anyone know how to make those encodings work also in html-textboxes?

    Can't get working with that UTF-8 conversion! Causes compiler exception while loading JSP page.
    Instead I tried this and it seems to work
    String salaryWish = request.getParameter("salaryWish");
    try
    salaryWish = new String(salaryWish.getBytes("ISO-8859-1"),"windows-1252");
    catch (Exception e){ }
    Anyway,
    thanks robert!

  • Applet loads in one jsp page and doesn't in the other

    Hi,
    I've got a strange problem. I've written an applet which I want to embed in a jsp page in a web application. I've created a very small web application to simplify testing the applet, and all works well in it. But when I try to embed the applet in my real web application (exactly the same way) it fails to init, firefox hangs, and in java console I get;
    java.lang.ClassFormatError: Incompatible magic value 168430090 in class file pl/cardq/applet/GameApplet1
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:178)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:778)
    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2045)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:707)
    at sun.applet.AppletPanel.run(AppletPanel.java:361)
    at java.lang.Thread.run(Thread.java:619)
    Any idea what that means?
    Thanks in advance

    Once the print window is open, click on "PDF", in the list of options you will find "open PDF in Preview".
    (I hope my translation is good because I am using French...)

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

Maybe you are looking for