You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Puneet Lakhina <pu...@gmail.com> on 2006/10/30 14:52:02 UTC

Setting enctype through javascript causing an exception

I have an html file field in my form. Basically to obtain input for certain
fields we have given user the option to either upload data through a file or
input it manually. Now I haven't set the enctype of the form in html form
tag but i set it using javascript whenever file input is selected.

But this doesn't work. It works only if i write <html:form action="/create"
enctype="multipart/form-data">

The reason why I want to set it using javascript is because in case the
manual input is large (about 400-500 values using indexed properties), my
application throws out of memory exception.

Any clues??


-- 
Puneet

Re: Setting enctype through javascript causing an exception

Posted by Puneet Lakhina <pu...@gmail.com>.
On 10/30/06, Puneet Lakhina <pu...@gmail.com> wrote:
>
> I have an html file field in my form. Basically to obtain input for
> certain fields we have given user the option to either upload data through a
> file or input it manually. Now I haven't set the enctype of the form in html
> form tag but i set it using javascript whenever file input is selected.
>
> But this doesn't work. It works only if i write <html:form
> action="/create" enctype="multipart/form-data">
>
> The reason why I want to set it using javascript is because in case the
> manual input is large (about 400-500 values using indexed properties), my
> application throws out of memory exception.
>
> Any clues??
>
>
> --
> Puneet

I removed the enctype from the form tag, and checked in my request processor
what is the content type of the request, and as it turns out the enctype
isnt getting set.

I dont know where am i going wrong

The follwing line gives an alert message multipart/form-data.

<html:form action="/create" onsubmit="alert(this.enctype)">
But in the request processor system.out.println(request.getContentType()). I
still get application/x-www-form-urlencoded.

Im guessing based on this that its not possible to set enctype using
javascript. is that true?? im really confused at this point of time.


-- 
Puneet