• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Submitting a text field along with a file?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic