aspose file tools*
The moose likes Struts and the fly likes Saving Marathi Language Data in Mysql database and same showing on another jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Saving Marathi Language Data in Mysql database and same showing on another jsp page" Watch "Saving Marathi Language Data in Mysql database and same showing on another jsp page" New topic
Author

Saving Marathi Language Data in Mysql database and same showing on another jsp page

andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

hi,
I am developing an application which takes Marathi language input and stores the same data in MySQL database.
I retrieve data and show on the jsp page in same Marathi font. But i am not able to get the data.It shows some garbage values or symbols for those Marathi values.
I have declared the input jsp page and display jsp page as UTF-8. The character set of table and columns which store those values have been declared as UTF-8.
Is there anything that i have to change so that the display page will show the same input as i am giving.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
It would seem that the data is garbled at some point through the system. Check at each point that the data is still the same you entered - upon receiving the form submission on the server, after storing it in the DB, after retrieving it form the DB on the server, and finally in the web browser within the HTML page.


Ping & DNS - my free Android networking tools app
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

as i am developing this application in struts1 , data is getting garbled before it comes to the action class through action-form .
i mean before coming to the java class . i am not getting why its getting garbled while passing through the action-form.Please help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
Which encoding is used to transfer the data from the HTML page to the server? Can you successfully post data to a servlet instead of a Struts Action? You could read the stream of data within the servlet and check the bytes are still correct there.
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

i am using UTF-8 page encoding.
given is the half part of ma input jsp......i am entring marathi input in the fields but it gets garbled before it reaches to action class.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
OK, that leaves this part:
Ulf Dittmer wrote:Can you successfully post the data to a servlet instead of a Struts Action? You could read the stream of data within the servlet and check the bytes are still correct there.
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

sory but i dint get you. how could i check whether servlet is getting that data or not. How could i access ActionServlet class which is controller for struts.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
Not an ActionServlet - a standard servlet, without any use of Struts. If you submit your form to that, you can examine the data that got sent in the doPost method. Are you familiar with servlets?

The point is to check whether your data even makes it to the server correctly. If a standard servlet receives the data correctly (mening it got sent over the wire OK), then I guess that Struts somehow doesn't handle it properly, although that doesn't sound likely.
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

thats the problem...i am not that much familiar with servlets....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
Then I'd suggest you learn servlets first before using a framework like Struts. As you're just finding out, frameworks hide some of the underlying the specifics that you need to understand in order to write web apps. Though proper round-trip handling of Unicode characters isn't rocket science, it isn't trivial either.

Or search for something like "struts encoding problem utf-8" or a similar combination of various other related terms.
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

yeah..i feel it too..thank you so much...if you get any solution in struts please let me know ...thank you again
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
if you get any solution in struts please let me know

Unlikely, as I will not look for a solution. And I'm not familiar enough with Struts to guess what the problem might be.
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

I am having data other than english language and want to pass that data to java class(Action) through ActionForm.But the value is getting garbled in betwwen.
I have mentioned pageEncoding utf-8 in page directive of jsp page. I also added acceptCharset tag to utf-8 in jsp form. i am getting this kind of text.... विनायक तात्या
i don't know whats remaining now. please help
andrew ronchi
Ranch Hand

Joined: Nov 03, 2011
Posts: 48

The problem can be solved by adding the following code to the actionform reset and validate methods:
view plaincopy to clipboardprint?

try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException ex) {
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving Marathi Language Data in Mysql database and same showing on another jsp page