You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Karsten Voges <ka...@jato-consulting.de> on 2007/02/15 11:31:52 UTC

Empty request parameters with enctype set to "multipart/form-data"

Hi list,

I downloaded Struts 2.0.5 (beta) and started developing of a small app 
(simple form submit) on Tomcat 5.5.17 (JDK 1.5). Its working quite good 
and I am happy with both the stability and the programming model.

Unfortunately I have a problem with some requests (form submitting) 
sending no request parameters at all (empty enumeration) and setting no 
fields of my actions. This mainly happens the first time the form gets 
submitted and mainly.
When I set the enctype parameter in the s:form with enctype = 
"application/x-www-form-urlencoded" the form gets submitted without a 
problem. All request parameters are set (checked via 
ServletActionContext.getRequest().getParameterNames()), all fields in 
the action are populated.
But to upload files I have to set the enctype to "multipart/form-data" :(

I found the following questions with the same problem, but no solution 
so far:
http://www.junlu.com/msg/309344.html
http://www.archivum.info/user@struts.apache.org/2006-12/msg00622.html

I have not special interceptors in place.
When no parameters are set, the fileinterceptor is not cleaning the tmp 
files, if the request is coming in well, the fileinterceptor is logging 
as well.

Of course I could seperate the rest of the form from the upload, but I 
am not to sure if this would work either.
I copied all the code over from struts2-showcase-2.0.5 regarding the 
fileupload and it is working most of the times, but not 100%.

The strange thing, is that it mainly happens the first time I submit, 
but not the following times, but sometimes it also happens a second or 
third time.
It never happens after it worked once, so after the form submit worked 
once fine it works fine always.

Any help much appreciated.
Thanks,
Karsten.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Empty request parameters with enctype set to "multipart/form-data"

Posted by "Hartrich, James CTR USTRANSCOM J6" <Ja...@ustranscom.mil>.
I believe there was a previous problem with FilterDispatcher.doFilter()
Cheers!

-----Original Message-----
From: Karsten Voges [mailto:karsten.voges@jato-consulting.de] 
Sent: Thursday, February 15, 2007 9:17 AM
To: Struts Users Mailing List
Subject: Re: Empty request parameters with enctype set to
"multipart/form-data"

Thanks a lot. This definitly helped.
Just pasted in the following code into web.xml and the error
disappeared:
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter
-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Strange that it needs this, but good to know that there is a fix for
this.

Cheers,
Karsten.


Andrew Stepanenko schrieb:
> Hello,
>
> http://www.archivum.info/user@struts.apache.org/2007-02/msg00012.html
>
> Regards,
> Andrew Stepanenko

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Empty request parameters with enctype set to "multipart/form-data"

Posted by Karsten Voges <ka...@jato-consulting.de>.
Thanks a lot. This definitly helped.
Just pasted in the following code into web.xml and the error disappeared:
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Strange that it needs this, but good to know that there is a fix for this.

Cheers,
Karsten.


Andrew Stepanenko schrieb:
> Hello,
>
> http://www.archivum.info/user@struts.apache.org/2007-02/msg00012.html
>
> Regards,
> Andrew Stepanenko

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Spanish characters

Posted by Borut Hadžialić <bo...@gmail.com>.
You must call request.setCharacterEncoding *before* you read anything
from your request.

The most convenient way to do this is using a filter, like mr. Zheng suggested.

On 2/15/07, Juan Espinosa <pc...@adinet.com.uy> wrote:
> Dou you mean that i must put in every jsp page something like this
>
> <%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>
>
> Juan
>
> -----Mensaje original-----
> De: Christopher Schultz [mailto:chris@christopherschultz.net]
> Enviado el: jueves, 15 de febrero de 2007 11:09
> Para: Struts Users Mailing List
> Asunto: Re: Spanish characters
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Juan and Zheng,
>
> Shuai Zheng wrote:
> > Add the following line into your web.xml
>
> It's only appropriate to use the CharacterEncodingFilter to force your
> requests to be UTF-8 if all your pages are being /served/ in UTF-8.
>
> Since you want to deal with "special" characters, you should set everything
> to UTF-8.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF1Glo9CaO5/Lv0PARAorUAKCAL0/IGrLHb6RtCTGx6CAvrlpJBgCgr6nS
> rIFEqFCSlJW2sz7XzYJORr0=
> =vk4l
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 14/02/2007
> 16:17
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 14/02/2007
> 16:17
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Why?
Because YES!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Spanish characters

Posted by Shuai Zheng <zh...@gmail.com>.
Juan is correct.

For myself, I just add the following line into every page:
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

And also, save all the page under UTF-8 mode. If you use Eclipse, you can
see the encode in file properties.

Regards,

Zheng Shuai

On 2/15/07, Juan Espinosa <pc...@adinet.com.uy> wrote:
>
> Dou you mean that i must put in every jsp page something like this
>
> <%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>
>
> Juan
>
> -----Mensaje original-----
> De: Christopher Schultz [mailto:chris@christopherschultz.net]
> Enviado el: jueves, 15 de febrero de 2007 11:09
> Para: Struts Users Mailing List
> Asunto: Re: Spanish characters
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Juan and Zheng,
>
> Shuai Zheng wrote:
> > Add the following line into your web.xml
>
> It's only appropriate to use the CharacterEncodingFilter to force your
> requests to be UTF-8 if all your pages are being /served/ in UTF-8.
>
> Since you want to deal with "special" characters, you should set
> everything
> to UTF-8.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF1Glo9CaO5/Lv0PARAorUAKCAL0/IGrLHb6RtCTGx6CAvrlpJBgCgr6nS
> rIFEqFCSlJW2sz7XzYJORr0=
> =vk4l
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date:
> 14/02/2007
> 16:17
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date:
> 14/02/2007
> 16:17
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Spanish characters

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Juan,

Juan Espinosa wrote:
> Dou you mean that i must put in every jsp page something like this
> 
> <%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>

My experience with JSP is very limited, but I think that you can change
the output encoding of all JSPs by modifying the server's web.xml where
the JSP compiler servlet is declared.

Check the archives for "jsp" and "utf-8". If you can't find anything,
ask again about how to force all JSPs to emit UTF-8.

Also, if you are fronting Tomcat with a web server such as Apache httpd,
you might need to make sure that the web server isn't modifying your
content type or response encoding headers.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF1IRY9CaO5/Lv0PARAkusAKCR3gQcLe+M+piwBhsJ05QoU6gDNgCgqyRx
Hkwvs/21p5OGQjJtm8d1/lQ=
=7aYr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Spanish characters

Posted by Juan Espinosa <pc...@adinet.com.uy>.
Dou you mean that i must put in every jsp page something like this

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

Juan 

-----Mensaje original-----
De: Christopher Schultz [mailto:chris@christopherschultz.net] 
Enviado el: jueves, 15 de febrero de 2007 11:09
Para: Struts Users Mailing List
Asunto: Re: Spanish characters

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Juan and Zheng,

Shuai Zheng wrote:
> Add the following line into your web.xml

It's only appropriate to use the CharacterEncodingFilter to force your
requests to be UTF-8 if all your pages are being /served/ in UTF-8.

Since you want to deal with "special" characters, you should set everything
to UTF-8.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF1Glo9CaO5/Lv0PARAorUAKCAL0/IGrLHb6RtCTGx6CAvrlpJBgCgr6nS
rIFEqFCSlJW2sz7XzYJORr0=
=vk4l
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 14/02/2007
16:17
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 14/02/2007
16:17
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Spanish characters

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Juan and Zheng,

Shuai Zheng wrote:
> Add the following line into your web.xml

It's only appropriate to use the CharacterEncodingFilter to force your
requests to be UTF-8 if all your pages are being /served/ in UTF-8.

Since you want to deal with "special" characters, you should set
everything to UTF-8.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF1Glo9CaO5/Lv0PARAorUAKCAL0/IGrLHb6RtCTGx6CAvrlpJBgCgr6nS
rIFEqFCSlJW2sz7XzYJORr0=
=vk4l
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Spanish characters

Posted by Shuai Zheng <zh...@gmail.com>.
Add the following line into your web.xml

 <filter>
  <filter-name>SetCharacterEncoding</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>

 <filter-mapping>
  <filter-name>SetCharacterEncoding</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>
 <filter-mapping>
  <filter-name>SetCharacterEncoding</filter-name>
  <url-pattern>*.action</url-pattern>
 </filter-mapping>

BTW: spring.jar must in your class path.

Regards,

Zheng Shuai

On 2/15/07, Juan Espinosa <pc...@adinet.com.uy> wrote:
>
>
> Hi, im having problems in my web application displaying spanish characters
> Anyone knows what i have to configure to work this properly
>
> For example if i put in a inputbox a Ñ character and submit that, then
> when
> the action
> returns to the "input" it show  strange characters like ??? Or !!! in the
> input box...
>
> Thanks
>
> Juan Espinosa
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date:
> 14/02/2007
> 16:17
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Spanish characters

Posted by Juan Espinosa <pc...@adinet.com.uy>.
 
Hi, im having problems in my web application displaying spanish characters
Anyone knows what i have to configure to work this properly

For example if i put in a inputbox a Ñ character and submit that, then when
the action
returns to the "input" it show  strange characters like ??? Or !!! in the
input box...

Thanks

Juan Espinosa

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.39/687 - Release Date: 14/02/2007
16:17
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Empty request parameters with enctype set to "multipart/form-data"

Posted by Andrew Stepanenko <an...@gmail.com>.
Hello,

http://www.archivum.info/user@struts.apache.org/2007-02/msg00012.html

Regards,
Andrew Stepanenko

On 2/15/07, Karsten Voges <ka...@jato-consulting.de> wrote:
> Hi list,
>
> I downloaded Struts 2.0.5 (beta) and started developing of a small app
> (simple form submit) on Tomcat 5.5.17 (JDK 1.5). Its working quite good
> and I am happy with both the stability and the programming model.
>
> Unfortunately I have a problem with some requests (form submitting)
> sending no request parameters at all (empty enumeration) and setting no
> fields of my actions. This mainly happens the first time the form gets
> submitted and mainly.
> When I set the enctype parameter in the s:form with enctype =
> "application/x-www-form-urlencoded" the form gets submitted without a
> problem. All request parameters are set (checked via
> ServletActionContext.getRequest().getParameterNames()), all fields in
> the action are populated.
> But to upload files I have to set the enctype to "multipart/form-data" :(
>
> I found the following questions with the same problem, but no solution
> so far:
> http://www.junlu.com/msg/309344.html
> http://www.archivum.info/user@struts.apache.org/2006-12/msg00622.html
>
> I have not special interceptors in place.
> When no parameters are set, the fileinterceptor is not cleaning the tmp
> files, if the request is coming in well, the fileinterceptor is logging
> as well.
>
> Of course I could seperate the rest of the form from the upload, but I
> am not to sure if this would work either.
> I copied all the code over from struts2-showcase-2.0.5 regarding the
> fileupload and it is working most of the times, but not 100%.
>
> The strange thing, is that it mainly happens the first time I submit,
> but not the following times, but sometimes it also happens a second or
> third time.
> It never happens after it worked once, so after the form submit worked
> once fine it works fine always.
>
> Any help much appreciated.
> Thanks,
> Karsten.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org