Need to help to retrieve the value of forms

Hi

I have confronted by a problem to retrieve the value of form where the type is -> enctype:"multi/form-data"

i can't use the method request.getParameter("valueOfForms") ;

i don't know Why ... the result of this method is null.

If i use the type by defaut that means : enctype:"application/x-www-form-urlencoded" i can retrieve the value of Form

Have you got an idea how can i resolve my problem?

thanks you

[464 byte] By [hanimichia] at [2007-11-26 19:08:52]
# 1
what upload method do you use?
brandooa at 2007-7-9 21:03:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

hi

i don't use common.fileUpload i use an program which was coded by developor. That program works correctly , i can upload through the server.

My problem is how can i retrieve value of my forms with form type= enctype: "multipart/form-data"

im going to illustrate by sample code :

< fom action="valid.jsp" name="general" enctype="multipart/form-data">

Name of File = < input type ="file " name =" fileUpload">

<input type="submit" value="ok">

</form>

< -file valid.jsp-->

<% String fileUpload = request.getParameter("fileUpload");

out.print(fileUpload);

%>

result of this page is null

so i wonder why can't i retrieve the value of this form

i read in several forums the probems come of type =" enctype:"multipart/form-data">

if you have an solution could you help me!!!

i'm blocking

thank you

hanimichia at 2007-7-9 21:03:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hi ,

It didn't work because the HTML is not valid - it needs to be valid at least to a certain degree.

A few problems I found:

opening < fom tag is misspelled, it should be <form ,

There's a space inside the type attribute and the name attribute, remove all spaces inside html attributes to ensure consistency in naming of request parameters and form fields.

Try this modified code it should work:

index.jsp

--

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

<html>

<head><title></title></head>

<body>

<form action="valid.jsp" name="general" enctype="multipart/form-data">

Name of File = <input type="file" name="fileUpload"/>

<input type="submit" value="ok"/>

</form>

</body>

</html>

valid.jsp

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

<html>

<head><title></title></head>

<body>

<% String fileUpload = request.getParameter("fileUpload");

out.print(fileUpload);

%>

</body>

</html>

Message was edited by:

appy77

appy77a at 2007-7-9 21:03:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
hi Sorry to answer later, i use what you 've preconized ; but it don't work i don't why . i always get an null result I would like to know why do you use like fileUpload attribute name? can't i use a attribute name of my choice ? thanks
hanimichia at 2007-7-9 21:03:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

You can use any attribute name you want, as long as the HTML input text field name , and the one used by request.getAttribute are exactly the same - no spaces , also the case should match.

I've tried the above code, and it prints the full path of the file bieng uploaded, it did not show null after I made the corrections.

If you are still having problems, create a fresh new file and copy the code exactly as you see it above and try it out.

appy77a at 2007-7-9 21:03:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...