Re: struts request encoding to utf-8 problem
In this case, you've isolated your problem to the database read/write phase, which means it's not a Struts issue. You'll need to look again at your database configuration and whatever middleware you're using to communicate with it (e.g. JDBC, Hibernate). The specifics will depend on your database backend, the middleware you're using and your own persistence code and configuration. L. well i don't think that's the problem in database configuration as there're other projects works with it fine concerning middleware, i'm using JDBC but i donno what should i do to make JDBC middleware compatible with utf-8 encoding here's a snapet of JDBC connection i used .. public Connection dbConnect(String db_connect_string,String db_userid, String db_password) { try { Connection conn = DriverManager.getConnection( db_connect_string, db_userid, db_password); System.out.println(connected); return conn; } catch (Exception e) { e.printStackTrace(); return null; } } public String getText() { String text = ; Statement statement = null; try { Connection conn = dbConnect(jdbc:oracle:thin:@localhost:1522:fat10g, test, t); statement = conn.createStatement(); String query = select * from test; ResultSet resultSet = statement.executeQuery ( query ) ; // get the last entered row in test table while ( resultSet.next () ) { text = resultSet.getString(test); } // text = new String(text.getBytes(), UTF-8); } catch(Exception e) { e.printStackTrace(); } finally //ensure statement is closed properly { try { statement.close () ; } catch ( SQLException e ) { } } return text; } public void saveText(String text) { Statement statement = null; try { Connection conn = dbConnect(jdbc:oracle:thin:@localhost:1522:fat10g, test, t); statement = conn.createStatement(); String query = insert into TEST (test) values (' + text + '); boolean result = statement.execute( query ) ; } catch(SQLException e) { e.printStackTrace(); } finally //ensure statement is closed properly { try { statement.close () ; } catch ( SQLException e ) {} } } what should i do to middleware ? -- View this message in context: http://www.nabble.com/struts-request-encoding-to-utf-8-problem-tp15041079p15061172.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts request encoding to utf-8 problem
i'm using struts 1.1, oracle 10g environment i'm facing a problem that i can't save special characters as ẻ, € from the page to database correctly though i used all the possible ways to set the encoding to utf-8 her's the code i used 1- in the.jsp page .. %@ page language=java pageEncoding=UTF-8 contentType=text/html;charset=UTF-8 % and in the header .. meta http-equiv=Content-Type content=text/html; charset=UTF-8/ and declare the form .. form method=post accept-charset=UTF-8 action=%=actionName% 2- i used an encoding filter ... package controller; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class EncodingFilter implements Filter { private String encoding = UTF-8; public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { request.setCharacterEncoding(encoding); filterChain.doFilter(request, response); } public void init(FilterConfig filterConfig) throws ServletException { String encodingParam = filterConfig .getInitParameter(encoding); if (encodingParam != null) { encoding = encodingParam; } } public void destroy() { // nothing todo } } and declared it as following in web.xml ... ?xml version = '1.0' encoding = 'UTF-8'? and .. filter filter-nameEncodingFilter/filter-name filter-classcontroller.EncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameEncodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping 3- in struts-config ... ?xml version=1.0 encoding= UTF-8 ? and .. controller contentType=text/html; charset=UTF-8 multipartClass=org.apache.struts.upload.CommonsMultipartRequestHandler nocache=true / the point is the the characters reaches the action class corectly but when i save to datbase an retrieve again it's viewed corrupted in the page any help please?? -- View this message in context: http://www.nabble.com/struts-request-encoding-to-utf-8-problem-tp15041079p15041079.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts request encoding to utf-8 problem
try : request.setCharacterEncoding(encoding); response.setCharacterEncoding(encoding); filterChain.doFilter(request, response); r^ S pozdravom Robert Slama SpiritLine s.r.o. Bernolakova ul. 1A 901 01 Malacky [EMAIL PROTECTED] gsm: +421 905 122 841 tel: +421 34 778 20 88 +421 34 778 20 89 fax: +421 34 778 20 90 http://www.spiritline.org wessam wrote / napísal(a): i'm using struts 1.1, oracle 10g environment i'm facing a problem that i can't save special characters as ẻ, € from the page to database correctly though i used all the possible ways to set the encoding to utf-8 her's the code i used 1- in the.jsp page .. %@ page language=java pageEncoding=UTF-8 contentType=text/html;charset=UTF-8 % and in the header .. meta http-equiv=Content-Type content=text/html; charset=UTF-8/ and declare the form .. form method=post accept-charset=UTF-8 action=%=actionName% 2- i used an encoding filter ... package controller; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class EncodingFilter implements Filter { private String encoding = UTF-8; public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { request.setCharacterEncoding(encoding); filterChain.doFilter(request, response); } public void init(FilterConfig filterConfig) throws ServletException { String encodingParam = filterConfig .getInitParameter(encoding); if (encodingParam != null) { encoding = encodingParam; } } public void destroy() { // nothing todo } } and declared it as following in web.xml ... ?xml version = '1.0' encoding = 'UTF-8'? and .. filter filter-nameEncodingFilter/filter-name filter-classcontroller.EncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameEncodingFilter/filter-name url-pattern/*/url-pattern /filter-mapping 3- in struts-config ... ?xml version=1.0 encoding= UTF-8 ? and .. controller contentType=text/html; charset=UTF-8 multipartClass=org.apache.struts.upload.CommonsMultipartRequestHandler nocache=true / the point is the the characters reaches the action class corectly but when i save to datbase an retrieve again it's viewed corrupted in the page any help please?? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts request encoding to utf-8 problem
i did add response.setCharacterEncoding(encoding), in EncodingFilter class but still output corrupted characters in the jsp :( i really need to solve this problem as soon as possible .. any help please ? -- View this message in context: http://www.nabble.com/struts-request-encoding-to-utf-8-problem-tp15041079p15041950.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts request encoding to utf-8 problem
wessam wrote: i'm using struts 1.1, oracle 10g environment i'm facing a problem that i can't save special characters as ẻ, € from the page to database correctly though i used all the possible ways to set the encoding to utf-8 [...] the point is the the characters reaches the action class corectly but when i save to datbase an retrieve again it's viewed corrupted in the page You've partially narrowed down the problem, which is good; now you need to narrow it down the rest of the way: - is the data written to the database correctly? (try verifying outside or Struts) - is the data retrieved from the database correctly in your action? In other words, you need to determine if the problem is with the save to or restore from the database, or whether the problem is with displaying the data from Struts. My guess would be that it's the save/retrieve, since you didn't mention anything you'd done to ensure communication with the database was preserving correct character encoding, in which case it would be outside the scope of Struts. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts request encoding to utf-8 problem
Please keep discussions on the mailing list rather than replying to anyone directly, so the archives are complete. In this case, you've isolated your problem to the database read/write phase, which means it's not a Struts issue. You'll need to look again at your database configuration and whatever middleware you're using to communicate with it (e.g. JDBC, Hibernate). The specifics will depend on your database backend, the middleware you're using and your own persistence code and configuration. L. On 23-Jan-08, at 12:27 PM, [EMAIL PROTECTED] wrote: Laurie Harper wrote: wessam wrote: i'm using struts 1.1, oracle 10g environment i'm facing a problem that i can't save special characters as ẻ, € from the page to database correctly though i used all the possible ways to set the encoding to utf-8 [...] the point is the the characters reaches the action class corectly but when i save to datbase an retrieve again it's viewed corrupted in the page You've partially narrowed down the problem, which is good; now you need to narrow it down the rest of the way: - is the data written to the database correctly? (try verifying outside or Struts) - is the data retrieved from the database correctly in your action? In other words, you need to determine if the problem is with the save to or restore from the database, or whether the problem is with displaying the data from Struts. My guess would be that it's the save/retrieve, since you didn't mention anything you'd done to ensure communication with the database was preserving correct character encoding, in which case it would be outside the scope of Struts. L. when i debug .. i see that the insert query string reaches to business layer correct insert into test (testcoulmn) values ('€'), but when i execute the query i look to database table and see it inserted corrupted to database but one of my team told me not to depend on seeing the character in database as in another project data was inserted to datbase as ??? but retrieving correctly to the page !! when i retrieve from database to view the data on the .jsp page, the character is retrieved corrupted to the action class i tried encoding the data retrieved from database to utf-8 again before setting in in the formBean to avoid that database encoding isn't utf-8 but it also didn't work !!! any other solutions i missed ?? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Quoted from: http://www.nabble.com/struts-request-encoding-to-utf-8-problem- tp15041079p15046261.html -- Laurie Harper Open Source advocate, Java geek: http://www.holoweb.net/laurie Founder, Zotech Software: http://www.zotechsoftware.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]