Latest news!

I find out that after removing resp.setContentType("text/html"); from
the doPost() method everything starts working!!!

By reading servlet spec, I figure out that doFilter get called before
Servlets' doPost()
Serlet 2.3 spec about filtering:
QUOTE
When the container receives an incoming request, it takes the first
filter
instance in the list and calls its doFilter method, passing in the
ServletRequest
and ServletResponse, and a reference to the FilterChain object it
will use.
END QUOTE

It still behaves a bit bifferent in IE (user can change encoding to
something else) and Firefox (encoding will be forced to one that set
by Filter)

--- code --
 public void doPost( HttpServletRequest req, HttpServletResponse resp
)
          throws IOException, ServletException
{
  StringBuffer out;
 // doing something and out HTML output in out ( StringBuffer)
.....

  resp.setContentType("text/html"); // <=== do we need this line??

  PrintWriter pw = resp.getWriter();
  pw.println(out.toString());
}
--- end code ---

In all examples where HTML get generated by servlet I see this line:
resp.setContentType("text/html");

In my case Filter sets Encoding.
Can anybody confirm that resp.setContentType("text/html"); is not
nessesary


Thanks!
Mark.

--- "Frank W. Zammetti" <[EMAIL PROTECTED]> wrote:

> Mark, have a look here:
> 
>
http://javawebparts.sourceforge.net/javadocs/javawebparts/filter/CharacterEncodingFilter.html
> 
> Just added that to JWP last weekend :)  It essentially calls
> request.setCharacterEncoding() with whatever you configure.
> 
> (Oops... ignore the description of the encodingScheme parameter...
> just
> realized I have a cut-and-paste error in the javadoc.  D'oh!).
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: [EMAIL PROTECTED]
> 
> On Wed, October 12, 2005 10:53 am, Mark said:
> > Hi everybody,
> > I've got a request from my client to force an encoding in the
> > browser, regardless what user have set.
> >
> > When I set encoding inside my filter to Windows-1257 in the HTML
> > source code I see only ?s:??? ????? ???.
> >
> > Is there any easy way to enforce browser to set proper encoding?
> >
> >
> > May be I need to setContent type after I obtain a writer in the
> > servlet?
> > Note, all outputs are generated by servlets:
> >
> > public void doPost( HttpServletRequest req, HttpServletResponse
> resp
> > )
> >       throws IOException, ServletException
> > {
> >   // do something
> >     resp.setContentType("text/html");
> >     resp.getWriter().println(output);
> > }
> >
> >
> > In MyFilter.doFilter() I do following:
> >
>
(HttpServletResponse)response).setContentType("text/html;charset=Windows-1257")
> >
> > I use 5.0.28 with Redhat 9.
> > Any input is welcome.
> >
> > Thanks!
> > Mark.
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > 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! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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

Reply via email to