Using textfields and file upload (MultipartContent) in same form

Hello.

I am experiencing problems in my form.

I have many textfields and I am saying request.getParameter("..") in some action.

I also have a fileupload in the same form and trying to read it from the same action.

But it seems that none of my request.getParameter() work.

They all become null. But If I remove the fileupload stuff it works fine.

So my question is.

Can you use fileupload and textfields in the same form? Or do I need to seperate the handling in to different forms and actions?

Shervin

[556 byte] By [asgshea] at [2007-11-26 21:26:09]
# 1
Hi asgshe,You can use both on same page but you cant use getparameter when the enctype="multipart/form-data"....so u need to read those parameter files using Servlet input and output stream.....
Chellama at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> Hi asgshe,

>

> You can use both on same page but you cant use

> getparameter when the

> enctype="multipart/form-data"....so u need to read

> those parameter files using Servlet input and output

> stream.....

Actually I am doing that.

That is not my problem. My problem is why my request.getParamter() from the textfields are null.

asgshea at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

For instance. Here is some sample code:

String isenabled = request.getParameter("isenabled");

String returnpage = request.getParameter("returnpage");

// Do some stuff

if(ServletFileUpload.isMultipartContent(request)) {

FileItemFactory factory = new DiskFileItemFactory();

ServletFileUpload upload = new ServletFileUpload(factory);

List /* FileItem */ items = upload.parseRequest(request);

//More stuff being done

Here my isenabled and returnpage are null.

But when I remove all my new fileupload stuff, things work just fine

and the isenabled and returnpage are not null.

asgshea at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hi,,Even i faced the same problem accepting null values...So i used to store values in session and will get them....
Chellama at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
> Hi,,> Even i faced the same problem accepting null> values...So i used to store values in session and> will get them....I cant really do that.I have 37 request.getParamters, and I cant put 37 objects in session.It would be too ugly.
asgshea at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi i had only one value so i went with that option....I tried in many ways but unable to find solution....Try using Hidden value...
Chellama at 2007-7-10 3:06:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...