• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving & retreiving image using struts1

 
Santhosh Puttu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Follow the tutorial in the link below..hope it will help you..


www.roseindia.net/struts/strutsfileuploadandsave.shtml
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic