Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Uploading Image To the server

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to upload an image from the jsp page. I want to store the same image with three names. For the first time the image is stored but it gives a NullPointer Exception at FileItem write method second time in the loop.
Please help.....
Code is

There is a NullPointerException at line 13 second time in the loop
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly is null?
What is the trace?

Edit: your code at its own makes less sense. You're doing it three times for all the files. Once the stream is already read, you can't read it again. Remove that for-loop and that session getting/setting. Just keep it simple and follow the user guide at commons fileupload homepage. Once you're finished with that all, you're free to duplicate the files using the usual java.io stuff.
 
Rajat Raina
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bauke
It worked the way you told but I still have a doubt. The request stored in the List can be saved as an attribute of session so that the List can be used mutiple times.I am a bit confused on this. That is way i have used that that session getting/setting.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is still inside the same code block. You can just access the same reference.
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic