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

how can i display an image on browser

ramesh kothakonda
Ranch Hand

Joined: Feb 14, 2006
Posts: 40
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,

The object oriented way of becoming "RICH" is by INHERITANCE<br />Whoever said money can't buy happiness, didn't know where to shop.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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" />

Consultant, Sima Solutions
I agree. Here's the link:
subject: how can i display an image on browser
It's not a secret anymore!