Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Display Image using struts2

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 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.

Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic