aspose file tools*
The moose likes Tomcat and the fly likes java html show img src is system path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "java html show img src is system path" Watch "java html show img src is system path" New topic
Author

java html show img src is system path

G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
Hi

i need to display image in html page which there in system path i mean outside of application path

calling file : /tomcat/webapps/student/jsp/first.jsp

image placed in : /images/img.gif so image is not there in tomcat folder itself

i used html is not working but same when i try with windows is working so any one please help me ASAP because i need to close the issue.


Thanks
Sathish kumar
SCJP, SCWCD
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15624
    
  15

G.Sathish kumar wrote:Hi

i need to display image in html page which there in system path i mean outside of application path

calling file : /tomcat/webapps/student/jsp/first.jsp

image placed in : /images/img.gif so image is not there in tomcat folder itself

i used html is not working but same when i try with windows is working so any one please help me ASAP because i need to close the issue.


A web server is not a file server. So to get a webserver to return an image file's contents, you have to provide a URL mapping and a transport mechanism.

In most webapps, the URL mapping is the built-in one that says that if the app server receives a URL and it can't determine anything else to do with it, it will take the part of the URL that follows the webapp context and precedes the query parameters and use it to locate a file-type resource relative to the base of the WAR (unless the root directory of that path is "WEB-INF"). Once the resource is located, the system will then open it and copy its contents to the response data stream.

Since you want to use an external location for shared resources, and there's no built-in mechanism that does that, you'd need to define a servlet that does the same thing as the built-in server function but knows to look in your "/images" directory instead of in an images directory in your WAR. It's a very simple servlet, since all it does is construct a file path, open the file at that path location (if there is a file there!), then copies it to the response writer stream. Probably 20 lines of Java code. You may even find one already written if you do a little web searching, since this is actually a fairly common thing to do.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java html show img src is system path
 
Similar Threads
How to get upload an image on server and get it on next jsp?
Struts and dynamic image sources.
How to display image giving dynamic path in HTML
how to display an image in a jsp through ajax
How Display image in a JSP that retrieved from a database?