This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display Image using struts2

 
ekansh singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 UploadProjectFileDB.java 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.

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