Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem accessing inputstream in servlet

 
Kalai Selvi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a jsp to prompt the user to upload a file



Once this form is submitted, control goes to servlet, which does some manipulation and calls a java program passing the input stream.

In that java program, i try to read the file thus uploaded using the inputstream. It says file not found.

Is there any possibility of the stream getting lost at the point when i try to open the uploaded file?

Note: I am trying to upload an excel file and open the same, using jexcel api. When i call that last java program from a jsp it is working fine. When i changed my program flow and added a servlet, it is not working now.

Pleass help.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd be much better off using an upload library.
We list some in the FileUpload FAQ

If, for some reason, you really want to implement this yourself, you'll want to keep in mind that you can either call getInputStream OR one of the methods that return parameters but not both. Once you call one of the latter methods, the servlet parses the input stream to get the parameters. Once parsed, it's no longer available to the getInputStream method.
 
li bei
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the jarkata common-fileupload lib.
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you open an uploaded file? Do you use something like:

?

Verify that your file didn't get deleted or reminded in write in condition.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic