Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

File Upload help

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am able to upload files through servlets. But the problem is my html form has several text fields apart from an upload field. Whenever I am using ENCTYPE="multipart/form-data" in my form..the file is getting uploaded but my request.getParameter() values are returning NULL.

Can anybody please help and let me know what I am supposed to change to make my application work with both uploading and returning the values keyed in by the user.

Thanks for the help.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getParameter doesn't work with multi-part forms. You will need to check the documentation for whatever upload library you are using to see how to retrieve your form variables.
 
ford Darcy Jr
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben Souther,

I am using com.oreilly.servlet.MultipartRequest for uploading my file. If possible can you please tell me what am I supposed to use instead of request.getParameter() for getting the values.

Thanks for the help.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to check the documentation for those libraries.
I believe MultiPartRequest provides a getParameter() or similar method.

I haven't used the O'Reilly upload tool in years so I'm not sure how it works.
 
ford Darcy Jr
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben Souther,

Thanks a lot..I will go through the documentation.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second Notice.

"Ford Ford"-
Please adjust your displayed name to your real name as written in the
JavaRanch Naming Policy.

You can change it

here.

Thanks!

Mark
 
ford Darcy Jr
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am able to upload files using servlets. But is there any way to restrict overriding of files and save using a different name ?

Thanks,
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ford Jr,
Sorry to nag, but I don't think you're trying hard enough to create a convincing display name.

There's no way for us to realistically check the real name of each and every visitor to the site, so we tend to accept anything which sounds 'good enough', but you're not there yet. I can offer a bunch of alternatives: Ford Simpson, Ford Ponting, Ford Smithon. All these created without taxing my brain at all.

Please try again. Unfortunately it's sometimes easier to delete the account and start from scratch, but we hope it doesn't come to that.

thanks,
Dave.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic