• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Relative path Issue

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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 ]
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic