RE: Q:how to remove charset from HTTP responce to allow browser use a browser selected charset?

2005-10-12 Thread Mark
Hi Rick,
Yes my data comes from different locales I should say it's a legacy
data. I have no ability co convert it to UTF-8 right now.

response.setContentType(text/html;charset=...); mess up the not
UTF-8 output, I'm getting ???s instead of a valid data.

I think I'll go with request.setCharacterEncoding(encoding);

Crossing my fingers...

Mark.
--- Rick [EMAIL PROTECTED] wrote:

 Hi Mark,
   Can you talk a little about what the data is.. Just form data
 from
 different locales?
 I store all my data in UTF-8 and just instruct the page encoding to
 be the
 same (UTF-8) and I'm able to handle input and display of whatever
 people
 enter. Had a few odd things to overcome to get it working like,
 
 JSP: I had to save the actual JSP file in UTF8 otherwise I couldn't
 get it
 to serve the page with UTF8 properly.. This started after Tomcat
 5.0.16 or
 something like that.  
 
 Servlet: don't think I had to do anything wild.. Just set the
 charset before
 you do anything with the output stream, including just getting a
 handle to
 the stream writer.  Set the contenttype first.
 response.setContentType(text/html;charset=UTF-8);
 
 Depending on what you are reading from and such. You may also want
 to set
 some Java ARGs when starting Tomcat... Like:
 -Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8
 -DjavaEncoding=UTF-8
 
 Not sure if this is relevant, but hope it helps,
 
 Rick
 
 -Original Message-
 From: Mark [mailto:[EMAIL PROTECTED] 
 Posted At: Thursday, October 06, 2005 12:13 PM
 Posted To: Tomcat Dev
 Conversation: Q:how to remove charset from HTTP responce to allow
 browser
 use a browser selected charset?
 Subject: Re: Q:how to remove charset from HTTP responce to allow
 browser use
 a browser selected charset?
 
 
 Hi Mark,
 In my case servlet generates an output, so no JSP for now...
 Can I do it using filters? Or define and store user's prefs with
 encoding
 outside of tomcat and  in the session and use if it's exists in the
 session?
 
 Thanks a lot!
 Mark.
 
 --- Mark Thomas [EMAIL PROTECTED] wrote:
 
  Mark wrote:
   Hello,
   
   In my application users enter data using different languages.
   The problem I'm facing is the browser sets the page encoding
  always
   to ISO-8859-1. (I guess this is default based on server OS)
   
   User can change encoding on the page (Browser settings) and 
   everything looks OK but only for one page. On the next page
  encoding
   is back to ISO-8859-1.
   Is there any way to instruct tomcat not to send the page
  encoding?
  
  If you are using JSPs, no. The spec requires that the charset is
 set.
  
  Mark
  
  
  
 

-
  To unsubscribe, e-mail:
 [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
  
  
 
 
 
   
   
 __
 Yahoo! for Good
 Donate to the Hurricane Katrina relief effort. 
 http://store.yahoo.com/redcross-donate3/ 
 
 

-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 

-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 




__ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Q:how to remove charset from HTTP responce to allow browser use a browser selected charset?

2005-10-07 Thread Bill Barker

Mark [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi Mark,
 In my case servlet generates an output, so no JSP for now...
 Can I do it using filters? Or define and store user's prefs with
 encoding outside of tomcat and  in the session and use if it's exists
 in the session?

Other Mark's answer was a little incomplete.  If your Servlet uses 
response.getWriter, then the spec requires that you get a charset on the 
Response headers.  If your Servlet doesn't specify a charset in the 
response.setContentType, then a Filter something like:

   public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain)
  throws ServletException, IOException {
if(request instanceof HttpServletRequest) {
HttpServletRequest hreq = (HttpServletRequest)request;
HttpSession session = hreq.getSession();
String enc = (String)session.getAttribute(MY_ENC_ATTR_NAME);
if(enc == null) {
 enc = getCharSetForUser(hreq); // Your lookup from DB 
function
 if(enc != null) {
 session.setAttribute(MY_ENC_ATTR_NAME, enc);
 }
}
if(enc != null) {
response.setCharacterEncoding(enc);
}
}
chain.doFilter(request, response);
   }



 Thanks a lot!
 Mark.

 --- Mark Thomas [EMAIL PROTECTED] wrote:

 Mark wrote:
  Hello,
 
  In my application users enter data using different languages.
  The problem I'm facing is the browser sets the page encoding
 always
  to ISO-8859-1. (I guess this is default based on server OS)
 
  User can change encoding on the page (Browser settings) and
  everything looks OK but only for one page. On the next page
 encoding
  is back to ISO-8859-1.
  Is there any way to instruct tomcat not to send the page
 encoding?

 If you are using JSPs, no. The spec requires that the charset is
 set.

 Mark




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]







 __
 Yahoo! for Good
 Donate to the Hurricane Katrina relief effort.
 http://store.yahoo.com/redcross-donate3/ 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Q:how to remove charset from HTTP responce to allow browser use a browser selected charset?

2005-10-06 Thread Mark Thomas

Mark wrote:

Hello,

In my application users enter data using different languages.
The problem I'm facing is the browser sets the page encoding always
to ISO-8859-1. (I guess this is default based on server OS)

User can change encoding on the page (Browser settings) and
everything looks OK but only for one page. On the next page encoding
is back to ISO-8859-1.
Is there any way to instruct tomcat not to send the page encoding?


If you are using JSPs, no. The spec requires that the charset is set.

Mark



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Q:how to remove charset from HTTP responce to allow browser use a browser selected charset?

2005-10-06 Thread Mark
Hi Mark,
In my case servlet generates an output, so no JSP for now...
Can I do it using filters? Or define and store user's prefs with
encoding outside of tomcat and  in the session and use if it's exists
in the session?

Thanks a lot!
Mark.

--- Mark Thomas [EMAIL PROTECTED] wrote:

 Mark wrote:
  Hello,
  
  In my application users enter data using different languages.
  The problem I'm facing is the browser sets the page encoding
 always
  to ISO-8859-1. (I guess this is default based on server OS)
  
  User can change encoding on the page (Browser settings) and
  everything looks OK but only for one page. On the next page
 encoding
  is back to ISO-8859-1.
  Is there any way to instruct tomcat not to send the page
 encoding?
 
 If you are using JSPs, no. The spec requires that the charset is
 set.
 
 Mark
 
 
 

-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 





__ 
Yahoo! for Good 
Donate to the Hurricane Katrina relief effort. 
http://store.yahoo.com/redcross-donate3/ 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Q:how to remove charset from HTTP responce to allow browser use a browser selected charset?

2005-10-06 Thread Rick
Hi Mark,
  Can you talk a little about what the data is.. Just form data from
different locales?
I store all my data in UTF-8 and just instruct the page encoding to be the
same (UTF-8) and I'm able to handle input and display of whatever people
enter. Had a few odd things to overcome to get it working like,

JSP: I had to save the actual JSP file in UTF8 otherwise I couldn't get it
to serve the page with UTF8 properly.. This started after Tomcat 5.0.16 or
something like that.  

Servlet: don't think I had to do anything wild.. Just set the charset before
you do anything with the output stream, including just getting a handle to
the stream writer.  Set the contenttype first.
response.setContentType(text/html;charset=UTF-8);

Depending on what you are reading from and such. You may also want to set
some Java ARGs when starting Tomcat... Like:
-Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8
-DjavaEncoding=UTF-8

Not sure if this is relevant, but hope it helps,

Rick

-Original Message-
From: Mark [mailto:[EMAIL PROTECTED] 
Posted At: Thursday, October 06, 2005 12:13 PM
Posted To: Tomcat Dev
Conversation: Q:how to remove charset from HTTP responce to allow browser
use a browser selected charset?
Subject: Re: Q:how to remove charset from HTTP responce to allow browser use
a browser selected charset?


Hi Mark,
In my case servlet generates an output, so no JSP for now...
Can I do it using filters? Or define and store user's prefs with encoding
outside of tomcat and  in the session and use if it's exists in the session?

Thanks a lot!
Mark.

--- Mark Thomas [EMAIL PROTECTED] wrote:

 Mark wrote:
  Hello,
  
  In my application users enter data using different languages.
  The problem I'm facing is the browser sets the page encoding
 always
  to ISO-8859-1. (I guess this is default based on server OS)
  
  User can change encoding on the page (Browser settings) and 
  everything looks OK but only for one page. On the next page
 encoding
  is back to ISO-8859-1.
  Is there any way to instruct tomcat not to send the page
 encoding?
 
 If you are using JSPs, no. The spec requires that the charset is set.
 
 Mark
 
 
 

-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 





__
Yahoo! for Good
Donate to the Hurricane Katrina relief effort. 
http://store.yahoo.com/redcross-donate3/ 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]