wood burning stoves 2.0*
The moose likes Struts and the fly likes saving & retreiving image using struts1 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 » Frameworks » Struts
Bookmark "saving & retreiving image using struts1" Watch "saving & retreiving image using struts1" New topic
Author

saving & retreiving image using struts1

Santhosh Puttu
Greenhorn

Joined: Jun 08, 2010
Posts: 27
I need to retrieve the image stored in database using struts.
I think i have inserted image in to my table by using following.

UserAction.java


User Faculty.java


UserFaculty.hbm.xml



UserFacultyDAO


sql query to store image is inside table: user_faculty
While creating table I have given datatype as BLOB for image attribute.

I try to display the saved image in as:

userinfo.jsp :


Output is not showing an image but some value like [B@189cab

I think i am wrong in displaying the image using JSP ,

Any help ranchers?
Prakash Mani - Attur
Ranch Hand

Joined: Oct 08, 2009
Posts: 100
can you please tell how you have saved image in the DB?(Just to know)

My suggestion, upload the image in to your server with unique file name and save the file name in your DB... when you want to retrieve the image get the file name from DB and read the file from the stored location...
Santhosh Puttu
Greenhorn

Joined: Jun 08, 2010
Posts: 27
I created one jsp page where user can select the photo stored.
Like:
<td align="right">Photo</td>
<td><html:file property="photo1" /></td>


User ll select the image.
I m taking this selected image & sending to UserInfo form ....
Where i am using seters and getters..

Any thing else you would need to know Prakash?
Prakash Mani - Attur
Ranch Hand

Joined: Oct 08, 2009
Posts: 100
Follow the tutorial in the link below..hope it will help you..


www.roseindia.net/struts/strutsfileuploadandsave.shtml
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I tend to steer people away from roseindia because of the poor quality of the examples. But the bottom line is that you'll need to stream the image blob to the client using a servlet or action. The linked roseindia example assumes it exists in a file, but the underlying technique is the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: saving & retreiving image using struts1
 
Similar Threads
Exception creating bean of class web.struts.form.CompanyRegistrationForm
jsp postgress connection
Error Creating SessionFactory
JDBC Driver class not found
using Multiple submit buttons.