File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Display  Image using struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Display  Image using struts2" Watch "Display  Image using struts2" New topic

Display Image using struts2

ekansh singh

Joined: Mar 05, 2009
Posts: 5
I am new to Struts.
I want to display image on JSP page and I am using Struts2 framework.
struts.xml file
I have uploaded the image in database.
the table is ---- filepool
- id as primary key, integer
- filename longblob data type
now i have a file imageUpload.jsp

there is one action class having attribute
private File file and its setter method
and in the execute method i have made database connection and it uploads the file to table. and return success.

my struts.xml file

now i want to display this image in the uploadDone.jsp
and i have no idea how to display this image.
In brief can you please tell me how to display an image from the database.

David Newton

Joined: Sep 29, 2008
Posts: 12617

Reading an image from a DB isn't a Struts question (and whether or not it's a good idea at all isn't either).

On the Struts 2 end you could either write the data back directly to the response and return a null instead of a result string, or use the built-in "stream" result type.
I agree. Here's the link:
subject: Display Image using struts2