This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes Submitting a text field along with a file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Submitting a text field along with a file? " Watch "Submitting a text field along with a file? " New topic
Author

Submitting a text field along with a file?

Antti Niemela
Greenhorn

Joined: Jan 07, 2010
Posts: 2
I'm in dire need of assitance. I have a form to upload a file onto a server, but I also need to pass a string (UUID) to the bit of code handling the file.

If I set the enctype to "multipart/form-data" the input "notification_parameter" containing the string is always null. I'm guessing it's impossible to submit a text field in the same form as a file, is this right?

I need some way to send the string. Any help is appreciated. The code is below.

Tapio Niemela
Ranch Hand

Joined: Jan 06, 2006
Posts: 77
mr Niemelä, you should check for Apache Jakarta Commons FileUpload project. As you are probably struggling with encoding too, please notice that you should have Filter for character endoding and then you should be aware of method String value = item.org.apache.commons.fileupload.FileItem(String charset);

Also pages should have following settings:
<%@page language="java" contentType="text/html;charSet=UTF-8" pageEncoding="UTF-8"%>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

also I think you might have to set response encoding..
response.setCharacterEncoding("UTF-8");

I hope this will help you..
Antti Niemela
Greenhorn

Joined: Jan 07, 2010
Posts: 2
Thank you, fellow Mr. Niemela!

This is quite embarrasing, but I had already added the UploadFile jar into my project, but had totally forgotten about it. Now with the FileUpload implementation, things work perfectly!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Submitting a text field along with a file?