Application Server Solutions for Microsoft IIS and ASP.NET
       solutions   products   partners   company   support   downloads         store
View Interest List Message Details
<< Back to Search Results

Date: 11/05/2007
From: GSL@syscomworld.com
Subject: SV: SV: [ServletExec] Character encoding issue with POST parameters

Thank your for replying so extensively.

The text is entered into a textarea, picked up by javascript and sent via       
XmlHttpRequest to a servlet. The problem occurs with both IE6 and Firefox 2.0,  
and I've confirmed that the Content-type header contains charset=UTF-8.

The hex string is thrown in an exception, which is then picked up by the        
client-side callback and displayed on the webpage.

I'll go through the rest of your suggestions tomorrow.

Glenn


________________________________

Fra: servletexec-interest-owner@newatlanta.com på vegne av                      
mmcginty@newatlanta.com
Sendt: ma 05.11.2007 21:21
Til: servletexec-interest@newatlanta.com
Emne: Re: SV: [ServletExec] Character encoding issue with POST parameters


Glenn,

The case of some letters being encoded properly while others are not seems      
quite odd to me... 

Are you using a browser and an HTML form to POST the request parameters?
Or are you using some sort of custom/non-standard client to send the request    
parameters?

To what are you sending the request parameters (a Servlet or a JSP)?

Are you printing the hex string to the browser? or to Standard out              
[System.out.println() ] or to some other file?

With SE, a call to request.getParameter() returns (by default) a String         
that's been  
encoded using the 8859_1 charset.

Also... I know that the request encoding can be configured globally in tomcat.
At least I know this is true with Tomcat 6.0.10 where it is configured in       
tomcat's              
/conf/server.xml file by changing (*for example*):

<Connector port="8080"                        
protocol="HTTP/1.1" 
             maxThreads="150"                    
connectionTimeout="20000" 
             redirectPort="8443" />

to this:

  <Connector port="8080"                      
protocol="HTTP/1.1"
             maxThreads="150"                    
connectionTimeout="20000"
             redirectPort="8443"
             URLEncoding="UTF-8" />


So maybe check your Tomcat settings as all things may not be set the same       
between Tomcat and SE.
Granted... using request.setCharacterEncoding() should override that... but it  
might still be prudent to understand any configuration differences that may be  
present in the 2 engine brands you are using.

And maybe consider applying the latest SE 5 hotfix (see SE FAQ #195) and seeing 
if doing *only* that changes the behavior any.
The latest one right now is the Sept 2007 hotfix.
It includes fixes for the following encoding-related bugs:

- bug #2283: Request.getCharacterEncoding() sometimes returns null when it      
should not
  (this can occur if the browser/client fails to send the request header named  
"Content Type")

- bug #1430: Character encoding not being honored for the body of a custom tag

which may or may not be impacting you.

If you are POSTing to a JSP then it may be prudent to "touch" it (add 
a harmless space and then remove it and re-save the file) before you re-request 
it.
If that does not change the behavior at all then:

1. if you are POSTing to a JSP, does it use the jsp:include tag or the          
jsp:forward tag?
2. can you send a simple example which I could run here to see the problem      
myself?


Also... consider that the Sept 2007 hotfix includes a fix for the following:
------
- bug #2792: Unable to configure the default request encoding
   This is now configurable by passing a System property to the JVM at JVM      
startup time.
   For example to change the default request encoding from 8859_1 to UTF-8:
   -Dcom.newatlanta.servletexec.request.url.encoding=UTF-8
------


So maybe try using that fix to see if it makes any difference in the behavior. 

Matt McGinty
Software Engineer
New Atlanta Communications, LLC
http://www.newatlanta.com <http://www.newatlanta.com/>  


Glenn Slotte wrote: 

Sorry, it's 5.0 of course. We use ISAPI on IIS6.
 
For testing purposes, I print the string as hex using getBytes(). This is right 
after getParameter(). 
 
Glenn

________________________________

Fra: servletexec-interest-owner@newatlanta.com på vegne av                      
mmcginty@newatlanta.com
Sendt: ma 05.11.2007 18:37
Til: servletexec-interest@newatlanta.com
Emne: Re: [ServletExec] Character encoding issue with POST parameters


Glenn,

Sorry for the problem you are having.
There is no ServletExec 5.5, so please clarify... which version of ServletExec  
are you using?
The login page of the SE Admin UI should tell you.

And are you using SE ISAPI or SE AS?

Also... where are the characters ending up as question marks?
In other words... are they being pulled from the request                        
[request.getParameter() ] and then being placed into a database and then        
retrieved from that database?
Or are they simply being pulled from the request and then displayed in the      
browser?

Glenn Slotte wrote: 

	Hi,
	 
	I'm trying to send UTF-8 encoded parameters with POST, but ServletExec    
5.5 fails to recognize certain characters. I use request.setCharacterEncoding(  
"UTF8" ) which helped but there are still some characters that end up 
as question marks.
	 
	The characters that now work are c3 a6, c3 b8 and c3 a5. The characters that   
do not work are c3 86, c3 98 and c3 85, which are simply the capitalized        
version of the former.
	 
	This works fine in Tomcat 5.5, even without manually setting the character     
encoding. It also works fine when manually creating a Java String from a UTF-8  
encoded byte array.
	 
	I appreciate any help you can offer.
	 
	Regards,
	Glenn Slotte
	-------------------------------------------------------------------------
	ServletExec-Interest. For archives and unsubscribe instructions, visit:
	
		    http://www.newatlanta.com/servletexec-interest.jsp
		  
	
	  


Message Thread
Date Subject Author
11/05/2007 SV: SV: [ServletExec] Character encoding issue with POST parameters GSL@syscomworld.com
11/06/2007 SV: SV: [ServletExec] Character encoding issue with POST parameters GSL@syscomworld.com
11/06/2007 Re: SV: SV: [ServletExec] Character encoding issue with POST parameters mmcginty@newatlanta.com
11/07/2007 RE: SV: SV: [ServletExec] Character encoding issue with POST parameters GSL@syscomworld.com
<< Back to Search Results


   
company media information terms of use privacy policy contact us