Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i display an image on browser

 
ramesh kothakonda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi java ranchers

how can i display an image on browser
here i am i am getting image name from date base table.
and all images are kept in c:\images directory .
At the time of string concatination I am getting syntax error and i tried so many ways but i did not get .

<html:image src="c:\\images/"+'<%= rooms.getThumbNail()%>'>


If you give an answer i will be thank full to you

thanking you,
k.ramesh
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramesh,
There is more than just a syntax error to watch out for here. The src attribute will be used by the browser to request the actual image. however, the browser cannot access the images directory on your server. It requires a URL beginning with http. This means you need to place the images on a webserver or as part of your web application.

If the images were on the user's machine, the URL would begin with file://c.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would look at writing a download Action class that extends org.apache.struts.actions.DownloadAction. By doing this, you can create a class that will either get the data directly from the database and output it to the output stream, or get the data from a file outside your web context and output it to the output stream. Once you've done this, you can simply code:

<html:img action="/myDownloadAction" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic