wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 41155
    
  45
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with Uploading Pictures using Jsp
 
Similar Threads
File object
How to store image in JSP from BLOB captured in Oracle
Couldn't able to insert image file in MySQL, Data truncation: Data too long for column 'image' at...
Store Images to database through Jsp
image insert problem