• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

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.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic