aspose file tools*
The moose likes Servlets and the fly likes Relative path Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Relative path Issue" Watch "Relative path Issue" New topic
Author

Relative path Issue

Madi Muthukumaran
Greenhorn

Joined: Oct 16, 2003
Posts: 11
Hi,

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.

ThanX in advance.

Regards,
Muthu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

"muthukumaran",

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.

Thanks!
bear
JavaRanch Sheriff
[ May 05, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joseph Erickson
Greenhorn

Joined: May 05, 2006
Posts: 10
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
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
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.

String mimiMappings[] = {"application/pdf pdf PDF", "application/msword DOC doc"};
MimetypesFileTypeMap mimeType = new MimetypesFileTypeMap();
mimeType.addMimeTypes(mimiMappings);

response.setContentType(mimeType.getContentType(certImagePath));
InputStream certFile = new FileInputStream(new File("ImageFile.jpg"));
OutputStream respOutStream = response.getOutputStream();

// 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();

Regards
Muthu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relative path Issue