The specific language characters are displayed as '?'
1 posts in topic
Flat View  Flat View

Posted By:   Fernando_OstanelLi
Posted On:   Tuesday, December 4, 2001 04:18 AM

I can´t show information in the HTML form correctly. When reading information from the database, the specific language characters like (ç,é, ã, and so on) are displayed as ?.
The same happens when recovering the HTML field using the meyhod getParameter().
What do I have to do to correclty set the charset and language to both: request and response ? Where can I find some examples or extra help ? Anyone can help me ?



Re: The specific language characters are displayed as '?'

Posted By:   Savvas_Christodoulou  
Posted On:   Wednesday, December 5, 2001 03:19 AM

Include this servlet in your project

Not in a servlet!In the whole project as an individual servlet.


package reserv;

import java.io.*;

// This class provides a way to convert a normal string to a unicode string, according to a charset

public class StringFixer


String charset;

public StringFixer(String acharset)


charset = acharset;


public void setCharset(String acharset)


charset = acharset;


public String fixit(String s)


try {

if (s == null) return null;

byte[] bytearr = new byte[s.length()];

for (int i = 0; i < s.length(); i++) bytearr[i] = (byte) s.charAt(i);

BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytearr), charset));

return reader.readLine();

} catch (Exception e) {


return s;





Post the variable you want as usual
but 'get' it as the example below

if the variable you post is 'category' then get it this way->

reserv.StringFixer sf1 = new reserv.StringFixer("utf-8");

category = sf1.fixit(request.getParameter("category"));

set the charset as below in your servlets


I hope that I help you!!!!

About | Sitemap | Contact