This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Problem with Uploading Pictures using Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Uploading Pictures using Jsp" Watch "Problem with Uploading Pictures using Jsp" New topic
Author

Problem with Uploading Pictures using Jsp

sravani
Greenhorn

Joined: Dec 06, 2008
Posts: 4
Hi,


My Requirement is to upload the images into database through jsp. For that i write a code .And it works fine .But in that File imgfile = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/test/Blue.jpg"); instead of that i used File imgfile = new File("Blue.jpg"); like that it didn't work. When we browse that image from local system it automatically takes like Blue.jpg and didn't take the full path.
So i got the error as " Blue.jpg not found". Please tell the solution how can i resolve my problem.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41050
    
  43
Web apps don't have a concept of a "default directory"; you always need to use full, absolute paths. Also, you should not perform I/O in a JSP; JSPs are meant to create HTML or similar texual output, not for any kind of computation. Move that code into a servlet or a backing bean instead. That's much more maintainable.


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"sravani",
Please check your private messages regarding an important administrative matter.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
jQuery in Action, 2nd edition
 
subject: Problem with Uploading Pictures using Jsp
 
Similar Threads
Couldn't able to insert image file in MySQL, Data truncation: Data too long for column 'image' at...
Store Images to database through Jsp
File object
image insert problem
How to store image in JSP from BLOB captured in Oracle