• Post Reply Bookmark Topic Watch Topic
  • New Topic

image JSP  RSS feed

 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have create a JSP and for it's header ;calling it's header.html. There is a image in Header.html.On every jsp there is this header.html and on my main jsp there are sevral link.

When I write address of image like this :<img alt="KDA" src="../static/logo.png" width="186" height="74"> Image will displayed when user click on the link and not on that main page and when I write address link this <img alt="KDA" src="/static/logo.png" width="186" height="74"> image will display only on main page not on other when I click on link...

Please Help!!!

Thanks
Divya
 
kaderjan wushouer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually I don;t get you,and can you tell us clearly?
are the resouces that link to are in the same directory?

you used same include *.html in each jsp pages,so you have to sure that those jsp which includes *.html is in same directory same as the main page
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on general Java.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I write address of image like this :<img alt="KDA" src="../static/logo.png"

Using page-relative addressing is not recommended within JSPs or anywhere within a web application.

You will be best served by using server-relative URL paths that begin with the context path.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's a server relative path? My complete path toward my image is "C:\Chetan\kdaWorkspace\JRECSWeb1\WebRoot\static\logo.png".

And I have mention on my header.html is "../static/logo.png".

Thanks

Divya
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the context path to your web application?

Let's assume that it's xyz and that the static folder is at its root. In that case, your URLs would be in the form of:



This way, the image URL is not dependent upon the current URL or location of any file other than the image itself.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for the reply!!!

But my image is still not displayed . My image is on WebRoot >> Static >> Logo.png.

And my JSP is in WebRoot >> Customer>> customer.JSP. i have mention the path on header.html i.e. WebRoot >>Static >> header.html.
is like "<img alt="KDA" src="/WebRoot/static/logo.png" width="186" height="74">" But still it's not displayed

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is WebRoot the context path to which you have mapped your application?

If so, you should be able to easily test from the browser by typing the URL of your image into the address bar.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question gets asked often enough that I have added a JSP FAQ entry for it.

Please check out:

http://faq.javaranch.com/java/ResourceUrlProblems

and be sure you are using the context path correctly.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ahve wroote path on html like this :

<html>
<head>
<title>header.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">




<link rel="stylesheet" href="../Theme/Master.css" type="text/css"></link></head>

<body>
<table width="100%" border="0">
<tr>
<td width="70%" rowspan="3">
<img src="C:\Chetan\kdaWorkspace2\JRECSWeb\WebRoot\static\logo.png"></img>

<td width="50%" id="headerTD">
<a href="">Home</a>  
<a href="">Main Menu</a>  
<a href=""> Help</a>  
<a href="">Logout</a>
</td>
</tr>

</table>


</body>
</html>

and calling this file on jsp as : <%@include file="\static\header.html"%>

Still not displaying image


thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66156
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<img src="C:\Chetan\kdaWorkspace2\JRECSWeb\WebRoot\static\logo.png"></img>
That doesn't even remotely resemble anything we've talked about.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!