On Wed, 4 Jul 2001, RUCH,SCOTT (HP-NewJersey,ex2) wrote:
>
> The issue of form data encoding has been discussed
> ad nauseum, however I didn't see anything in the
> archives regarding how one deals with arbitrary
> encodings when using Struts form beans.
>
> The introduction of ServletRequest.setEncoding()
> in 2.3 helps alleviate the form data encoding issue,
> but can Struts form bean users capitalize on this
> enhancement? setEncoding() needs to be called before
> any of the form data is processed. By the time the
> action servlet gains control, the form bean has been
> populated with the form data using some default encoding.
> The various commercial J2EE application servers have
> proprietary ways of specifying a form data encoding,
> but I (for one) would like to see a generic way of
> handling this in Struts that doesn't require a
> different configuration per app server.
>
> (BTW: is there a way to set form encoding on a
> per-web-application basis in Tomcat 3.2 or 4.0? I
> haven't been able to find any info about this...)
>
You could certainly do this with a Filter, which is another feature of the
Servlet 2.3 API enhancements. The basic idea would be to write a Filter
than examined the request headers, and then called
request.setCharacterEncoding() with an appropriate encoding value *before*
the Struts controller servlet ever saw the request. Because Tomcat 4.0
supports Servlet 2.3, this is certainly a viable strategy.
> Is any thought being given to allowing the JSP
> developer to specify the encoding of form data using
> attributes in Struts tags - or through some other
> mechanism?
>
The problem with that approach is that the Struts tags are processed when
the page is created, not when the subsequent request is received and
processed.
> --
> Scott W. Ruch hewlett-packard company
> [EMAIL PROTECTED] hp bluestone software
> 856.638.6036 http://www.bluestone.com
>
Craig McClanahan