• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in importing html file in jsp

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

I have create a static header.html so that on my everrry JSP I can call that header file. In that header file I have added comman link and company logo. But when I try to import html file : <%@ include file ="/static/header.html" %>

Image will not display on jsp.

In html page I add image like :<img src="logo.png" width="186" height="74"></img>

Please help
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<img src="logo.png"
Page-relative addressing should be avoided in web apps. Use server-relative addressing instead beginning with the conext path.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to do server relative referencing??
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I have written the full path i.e. "C:\Documents and Settings\cjain\workspace\CustomerWeb\WebRoot\static\logo.png" . It's show's in the preview option of Myeclispe .But not when I run on tomcat and also image is not displayed when I use Mozilla .. No even a cross sign of image.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by divya sharma:
Now I have written the full path


Not the right way.

Let's ay your context path is xyz and you images are in a folder named images at the context root. The URL for usch an image would be:

src="/xyz/images/something.gif"

Once you've got that working, we can discuss how to dynamically determine the context path.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks !!

Now, it working HTML file but when I importing that header.html in jsp then it's still not displayed image .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the renderred HTML look like as sent to the browser?
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my HTML :
<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="..\static\logo.png" width="186" height="74"></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>
--------------------------------------------------------------------------
And import statemnet that I have mention is jsp
<%@include file="\static\header.html"%>

Thanks!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The image URL is not formatted as I described.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

My image is on "Static" folder and if wrote path as "/WebRoot/Static/Header.html" Then image not even show in html page.

Thanks!!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the URL of the page as it appears in the address bar, and post what URL makes the image successfully appear if you type it in by hand.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Thanks a ton for your help!!!

I dont know what what happen but it's working now. I wrote <img src="static/logo.png"></img> on HTMl file and now its working in both html & jsp

Once again Thanks for your help and your time .. Now atlest I can start my work .

Thanks!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!