Multipart http request loosing parameters after first access.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multipart http request loosing parameters after first access.

Amey Jadiye
Hi,

Can I get any help for below from struts community please ?

-Amey
---------- Forwarded message ----------
From: "Amey Jadiye" <[hidden email]>
Date: Apr 9, 2017 12:14 AM
Subject: Multipart http request loosing parameters after first access.
To: <[hidden email]>
Cc:

Hi All,

I'm using struts 1.2.9 and having requirement to upload  and process file,
obviously struts is handing multi-part request quite well however i'm
having some existing logic where we have created my own filter from where
all requests pass and i check authorization of user whether he is allowed
to send that request or not.

as struts handle multipart request in its own doFilter and beyond that code
and i need few of the request parameters in my own filter(before populating
form fields) i wrote some code and used Commons FileUpload jar (1.3.2) as
below in my filter.

        List<FileItem> items = new ServletFileUpload(new
DiskFileItemFactory()).parseRequest(request);

and i'm getting all the form fields and queryparams in the list, now the
problem is all those parameter are lost once i parsed request here, and
now  from request object and BeanUtil.populate can't set my FormBean. :( as
request object dont have it.

I saw code of commons fileupload but doesn't seems anything odd code which
is flushing all those parameters Can someone let me know if i'm missing
something here ?

Thanks,

Amey
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multipart http request loosing parameters after first access.

Christoph Nenning
Hi,


please note that struts1 as been EOL'd long time ago. You should consider
migrating to struts2.


The behavior you describe is correct: after your filter has consumed
InputStream it is not available anymore for struts to process it. Just
last week there was another thread on this list regarding this topic.
Search the archives for "What is the best way to get all JSON params in
custom Interceptor to log them all in a custom logger ?".

In your case you could use a workaround: put the paramters you need to
check in URL instead of POST-body.


Regards,
Christoph



> From: Amey Jadiye <[hidden email]>
> To: [hidden email],
> Date: 10.04.2017 11:14
> Subject: Multipart http request loosing parameters after first access.
>
> Hi,
>
> Can I get any help for below from struts community please ?
>
> -Amey
> ---------- Forwarded message ----------
> From: "Amey Jadiye" <[hidden email]>
> Date: Apr 9, 2017 12:14 AM
> Subject: Multipart http request loosing parameters after first access.
> To: <[hidden email]>
> Cc:
>
> Hi All,
>
> I'm using struts 1.2.9 and having requirement to upload  and process
file,
> obviously struts is handing multi-part request quite well however i'm
> having some existing logic where we have created my own filter from
where
> all requests pass and i check authorization of user whether he is
allowed
> to send that request or not.
>
> as struts handle multipart request in its own doFilter and beyond that
code
> and i need few of the request parameters in my own filter(before
populating
> form fields) i wrote some code and used Commons FileUpload jar (1.3.2)
as
> below in my filter.
>
>         List<FileItem> items = new ServletFileUpload(new
> DiskFileItemFactory()).parseRequest(request);
>
> and i'm getting all the form fields and queryparams in the list, now the
> problem is all those parameter are lost once i parsed request here, and
> now  from request object and BeanUtil.populate can't set my FormBean. :(
as
> request object dont have it.
>
> I saw code of commons fileupload but doesn't seems anything odd code
which
> is flushing all those parameters Can someone let me know if i'm missing
> something here ?
>
> Thanks,
>
> Amey

This Email was scanned by Sophos Anti Virus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multipart http request loosing parameters after first access.

Norbert Hirneisen
Hello,

we are still using Struts 1.3.8 in a big project. And we are definetely
not considering migrating to struts2. Because struts2 is a totally
different framework - so no advantage to move to struts2 instead of
another framework. So just pick the best solution for the future.

For us a long term maintanance is important. And a smooth migration. So
we made the decision to migrate to a more service based architecture
using JSON/REST with golang server and also some Spring middleware.

Just check which architecture is suiting you best and keep the Struts1
running. Perhaps update to 1.3.10.

The EOL is not really an argument. Struts2 will have an EOL too.

Just my two cents

Norbert

(Struts 1 in production since 2003)



Am 10.04.2017 um 11:27 schrieb Christoph Nenning:

> Hi,
>
>
> please note that struts1 as been EOL'd long time ago. You should consider
> migrating to struts2.
>
>
> The behavior you describe is correct: after your filter has consumed
> InputStream it is not available anymore for struts to process it. Just
> last week there was another thread on this list regarding this topic.
> Search the archives for "What is the best way to get all JSON params in
> custom Interceptor to log them all in a custom logger ?".
>
> In your case you could use a workaround: put the paramters you need to
> check in URL instead of POST-body.
>
>
> Regards,
> Christoph
>
>
>
>> From: Amey Jadiye <[hidden email]>
>> To: [hidden email],
>> Date: 10.04.2017 11:14
>> Subject: Multipart http request loosing parameters after first access.
>>
>> Hi,
>>
>> Can I get any help for below from struts community please ?
>>
>> -Amey
>> ---------- Forwarded message ----------
>> From: "Amey Jadiye" <[hidden email]>
>> Date: Apr 9, 2017 12:14 AM
>> Subject: Multipart http request loosing parameters after first access.
>> To: <[hidden email]>
>> Cc:
>>
>> Hi All,
>>
>> I'm using struts 1.2.9 and having requirement to upload  and process
> file,
>> obviously struts is handing multi-part request quite well however i'm
>> having some existing logic where we have created my own filter from
> where
>> all requests pass and i check authorization of user whether he is
> allowed
>> to send that request or not.
>>
>> as struts handle multipart request in its own doFilter and beyond that
> code
>> and i need few of the request parameters in my own filter(before
> populating
>> form fields) i wrote some code and used Commons FileUpload jar (1.3.2)
> as
>> below in my filter.
>>
>>          List<FileItem> items = new ServletFileUpload(new
>> DiskFileItemFactory()).parseRequest(request);
>>
>> and i'm getting all the form fields and queryparams in the list, now the
>> problem is all those parameter are lost once i parsed request here, and
>> now  from request object and BeanUtil.populate can't set my FormBean. :(
> as
>> request object dont have it.
>>
>> I saw code of commons fileupload but doesn't seems anything odd code
> which
>> is flushing all those parameters Can someone let me know if i'm missing
>> something here ?
>>
>> Thanks,
>>
>> Amey
> This Email was scanned by Sophos Anti Virus
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...