This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes Retrieving unicode stuff from MySQL... get load of mess... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Retrieving unicode stuff from MySQL... get load of mess..." Watch "Retrieving unicode stuff from MySQL... get load of mess..." New topic
Author

Retrieving unicode stuff from MySQL... get load of mess...

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Hey!



I�m trying to make it so that my clients could use different languages when entering stuff into my froms. What I am doing right now is:



All my pages have <%@ page language="java" contentType="text/html; charset=UTF-8" at the top
When I retrieve parameters I use the following procedure:


String text = request.getParameter("text");

text = new String(text.getBytes("8859_1"),"UTF8");



This seems to work perfectly for throwing parameters from page to page. Also, it seems to work fine to ENTER stuff into MySQL (I look at mysql through GUI client, and I can see all my Unicode stuff correctly).



However, what is troubling me, is that when I retrieve that Unicode stuff from DB and try to display it, I get a whole bunch of junk on my page. Here�s how I retrieve it:




And in my JSP page I simply display name and message from the list returned by this function�

Does anyone know how to make my JSP page display my stuff correctly? I also tried doing:



<%= new String(message.getBytes("8859_1"),"UTF8") %>



But that just gives me a whole bunch of boxes instead of text.



Any help is greatly appreciated.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
is your browser capable and set up to display Unicode?
Many browsers won't automatically switch to another character encoding even when the HTTP headers contain a different encoding from the currently active one.


42
Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
If I accept input in one page, and display it in another, everything works fine (if its in Russian or English - doesnt matter)...

Even if I embedd it into my HTML or my SOurceBundles - everything works just fine...

Even when I store it into database, I can acess database with mysqlCC, and I can see the text in Russian/English in my records...

But if I retrieve stuff from database like I showed above, i get a load of crap for Russian, but everything's fine for English....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving unicode stuff from MySQL... get load of mess...
 
Similar Threads
error showing while retrieving the data from drop down list
Running Servlets on Linux
JSP table pagination is not working
Paging in jsp
Returning a 0 value error