File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how to load an image without using context root 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 » Java » JSP
Bookmark "how to load an image without using context root" Watch "how to load an image without using context root" New topic
Author

how to load an image without using context root

shwetank singh
Greenhorn

Joined: Apr 02, 2007
Posts: 26
Hi

This may sound absurd, yet i can use some thoughts here!
i've a jsp which has link to an image http://<server_ip>/context-root/largeImages/Collection/a.jpg
this will search and load an image a.jpg which should be under the context-root

what i wish to understand is,
a) is it possible, without changing this line of code, to somehow refer the image without context-root, if the image is not on same machine which has the servlet container?
b) if doing this is not possible without changing code, what changes should be brought about so that the image could be loaded provided hosting configuration stated above.

~ access the image as /largeImages/Collection/a.jsp and not /context-root/large...

please help!
thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

If the image is remote, you need to provide the entire URL.

If all remote resources are coming from the same place, you can shorten the URL by using the <base> HTML tag, but that affects all URLs so you can only use it if you want it to apply to all images, style sheets, links and script files.

Are you just looking for a shorthand for the pages?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shwetank singh
Greenhorn

Joined: Apr 02, 2007
Posts: 26
Hi Bear
Thanks for reply!
here is a background on where this question comes from:
i have an ear (having dynamic and static content) which has some jsp's that refer to images in below stated fashion (absolute path).
i have, to leverage upon powers of app server, moved the static content to a web-server and serve it from there.
this is done using plugins and directives used on webserver..an alias in httpd.conf tells the webserver...if a resource request comes with /context-root/... , it will be served by app server, or else the webserver can handle that (we can conveniently overlook this lest this becomes a question for server forums )

now to the problem..we already have so many jsp's having absolute path (url's to images/css etc.) that making a change everywhere is..what to say : )
and hence the question: can i refer to a static resource without using context-root?
>the image is remote.
>yes all resources will come from webserver and we can put them up into any structure in document-root.
>no this essentially is not a shorthand. i am trying to figure out a way to lookup a resource without actually referring to the context-root

please suggest further.
Thanks!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to load an image without using context root
 
Similar Threads
Context Root be only /
Working with Image Icon
How to load an image to display
Uploaded documents / images do not show up
BLOB(image) -> ByteArrayOutputStream -> display on screen