I am in need of help from you guys, it's very very urgent.
I will try to explain the problem. I have images stored in my server hard disk say (C:\AllImages). No I need to display the images in my web page, using the <img src=""> tag.
Now the problem is that the application server is in different folder say (F , now how will I give the relative path for the images stored in the C:
Is there any way to implement this thing. Kindly reply as soon as possible.
I deploy my application as a war, the app server can be Weblogic, Jboss, was.
There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
You won't be able to link directly to those images because they aren't in the web server's directory, but you might be able to link that folder into the web server's root document directory on the F drive. In Windows land, this would probably be done by a shortcut. You could make a shortcut of C:\Allimages, call it "images", and drop the shortcut into the Web Server's root document folder. Then the img tag should be <img src="/images/blah.gif" />
Do you know what the document root folder is for the web server?
Madi Muthukumaran
Greenhorn
Joined: Oct 16, 2003
Posts: 11
posted
0
Hi,
ThanX for your reply,
I tried in Websphere 5.2, actually my application will in the form of a war file (Sample.war), so when i deployed it, it will be extracted in the <<websphere_Installation_folder>>\installedapps\nodename\Sample.war. After i deployed i went there and created a shortcut to the mage folder in F driver. But it is not working.
I tried your option but it's not working. When i try to access image from the browser, i am getting "HTTP 404" error.
Is there any other way to that.
Regards.
Madi Muthukumaran
Greenhorn
Joined: Oct 16, 2003
Posts: 11
posted
0
Hi Thanx every one for the ur reply, i found out the solution for the issue. Instead of displaying the image using the image tag, we can directly read the image file and write it to the output stream of the response object. Following is the code sample.
// Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = certFile.read(buf)) > 0) { respOutStream.write(buf, 0, len); } certFile.close(); respOutStream.flush(); respOutStream.close();