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

Eclipse fileupload no longer works

 
Paul Bartels
Greenhorn
Posts: 11
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to migrate an app I wrote with a text editor into Eclipse and am finding that it's no easy task.

Numerous hurdles have been leaped over but this one has me stumped.
I have a servlet to upload an image (chosen by the user) and write it to the users account folder on the server.
Goes a little like this:


there's some Japanese in the comments there if you're getting funny symbols
I put in a whole lot of printlns to see where it broke and it's at the:
item.write(uploadedFile);
line.

Here's the console dump:
and on it goes... but that's probably enough.

Am I using the wrong upload class?
Should I use something in Eclipse instead of Apache?
What's with that huge file name in the FileNotFoundException?

I sure would like to know what is going on here.
It was working before I moved it onto Eclipse, by the way.

Oh, and you probably want to know that I'm using:
Eclipse Java EE IDE for Web Developers.
Build id: 20090920-1017

Much appreciated if any Eclipse experts out there could shine a light on this one for me.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Bartels wrote:What's with that huge file name in the FileNotFoundException?

That would be the huge clue pointing at what's wrong. Too much code in one method and too many superfluous comments to find it, though.

I can tell you what browser you're using to do the upload, though.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should read the javadoc for the File constructor, specifically what you get when you do this:

uploadedFile = new File(realPath, fileName);

Your printlns printed out the values of realPath and fileName, so the long resulting file name should not be any surprise.

By the way, this post has nothing to do with Eclipse.
 
Paul Bartels
Greenhorn
Posts: 11
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the comments.
I'll check out the javadocs and see if I can't get a proper file name going somehow.
 
Paul Bartels
Greenhorn
Posts: 11
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed it by cropping the file name to everything after the last File.seperator.
Sorry for wasting everyone's time. ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic