jQuery in Action, 3rd edition
The moose likes JSP and the fly likes <img> tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "<img> tag" Watch "<img> tag" New topic
Author

<img> tag

Ganesh Podaralla
Greenhorn

Joined: Feb 22, 2010
Posts: 23
Hi,

I am trying to import an image under my application context.

I know that there are two ways to place the file location under src.

Absolute Path: <img src="http://www.someweb.com/webapp/logo.jpg" >

Relative Path: <img src=logo.jpg"> which displays the image based on the location of the jsp.
<img src="/webapp/logo.jpg"> which displays the image from the application context relative path. In this case, we need to mention the application context path (webapp). How can I display the image relative to the context path but without mentioning the context (webapp)? Is there anyway I can avoid mentioning "webapp" in <img src="/webapp/logo.jpg"> ??

Thanks,
Ganesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63227
    
  69

This is covered in the JSP FAQ. You can obtain the context path programmatically and should never hard-code it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ganesh Podaralla
Greenhorn

Joined: Feb 22, 2010
Posts: 23
Thanks Bear Bibeault...That really helps..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63227
    
  69

 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: <img> tag
 
jQuery in Action, 3rd edition