Hi
Following codes are in one of my ActionForm classes
-------------------------------------
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
try {
this.firstname = new String(firstname.getBytes("UTF-8"), "UTF-8");
}
catch (UnsupportedEncodingException ex) {
}
}
-----------------------------------------
Discussions
Web tier: servlets, JSP, Web frameworks: Struts and UTF-8 encoded strings in fields of a form
-
Struts and UTF-8 encoded strings in fields of a form (4 messages)
- Posted by: Majid Makki
- Posted on: July 13 2004 06:29 EDT
Threaded Messages (4)
- Struts and UTF-8 encoded strings in fields of a form by Majid Makki on July 13 2004 06:49 EDT
- Struts and UTF-8 encoded strings in fields of a form by Senthil Chinnaiyan on July 13 2004 07:52 EDT
-
Struts and UTF-8 encoded strings in fields of a form by Majid Makki on July 14 2004 02:51 EDT
- It's solved by Majid Makki on July 14 2004 07:19 EDT
-
Struts and UTF-8 encoded strings in fields of a form by Majid Makki on July 14 2004 02:51 EDT
- Struts and UTF-8 encoded strings in fields of a form by Senthil Chinnaiyan on July 13 2004 07:52 EDT
-
Struts and UTF-8 encoded strings in fields of a form[ Go to top ]
- Posted by: Majid Makki
- Posted on: July 13 2004 06:49 EDT
- in response to Majid Makki
***** The first message was incomplete ******
***** Here is the corrected one ******
Hi
Following codes are in one of my ActionForm classes
-------------------------------------
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
try {
this.firstname = new String(firstname.getBytes("UTF-8"), "UTF-8");
}
catch (UnsupportedEncodingException ex) {
}
}
-----------------------------------------
After using input field (named firstname) of the relevant <html:form> fields in order to add a row to DB, content of this field are not inserted to the DB correctly. This content is in Persian(Farsi). I mean instead of a persian word, there are some unknown symbols in the database.
I want to know if there is a sure way to make the encoding of the content UTF-8 for all phases of processing.
Aside: I'm sure there's something done undesireably about the encoding of the content before ActionClass.execute(...) is called.
Thanks -
Struts and UTF-8 encoded strings in fields of a form[ Go to top ]
- Posted by: Senthil Chinnaiyan
- Posted on: July 13 2004 07:52 EDT
- in response to Majid Makki
Just to make sure, check your database character set encoding also. If you use oracle this might help you: http://dnaugler.cs.semo.edu/oracledocs/a90842/ch12.htm
Senthil. -
Struts and UTF-8 encoded strings in fields of a form[ Go to top ]
- Posted by: Majid Makki
- Posted on: July 14 2004 02:51 EDT
- in response to Senthil Chinnaiyan
I'm sure it's not caused by anything but the ActionForm.
When user types persian words in the field, if the validate method returns non-empty ActionErrors, some unknown symbols will be shown instead of the persian words.
Thanks again
Majid Makki -
It's solved[ Go to top ]
- Posted by: Majid Makki
- Posted on: July 14 2004 07:19 EDT
- in response to Majid Makki
It's solved by adding the following code fragment to the begining of reset(,) and validate(,) methods in ActionForm:
_______________________________________
try {
request.setCharacterEncoding("UTF-8");
}
catch (UnsupportedEncodingException ex) {
}
________________________________________
Thanks for your care