Solved

<jsp:include> not working properly

Posted on 2010-08-12
13
701 Views
Last Modified: 2012-06-21
Hi ,

I have header.jsp that have menu thats have .
i inculd in one page it working fine but in another page its not workinng. it not picking the JS file correctly i dont why ?

 I attach 3 jsp plz look at this
1 st Jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>


<html:html>
<link rel="stylesheet" type="text/css" href="css/bioOrigin.css.css">
<head>
<title>Report Generation</title>
<div>
<jsp:include page="/header.jsp" />
</div>
<table style="WIDTH: 1224px; HEIGHT: 65px" height="45" cellspacing="1"
	cellpadding="1" width="1240" summary="" border="0">
	<tbody>
		<tr>
			<td bgcolor="#006666"><font face="Arial">
			<h3 align="center"><b><font face="Arial" size="5"><bean:message
				key="title.report" /></font></b></h3>
			</font></td>
		</tr>
	</tbody>
</table>

</head>

<body bgcolor="white">
<fieldset align="center" style="width: 50%;"><form
 method="post">

	<table border="0" width="100%" align="Center" bgcolor="4A9586">
		<tr>
			<td align="center" width="80%">&nbsp;</td>
			<td align="right" width="30%"><font face="Arial" size="1"><input
				type="button" onClick="returntoHome()"
				value="<bean:message key="button.report.back"/>" /></font></td>
		</tr>
	</table>
	<fieldset style="border-color: BDFFEA">
	<table border="0" width="100%" align="left">
		<tr>
			<td bgcolor="skyblue"><strong><font face="Arial"><font
				size="2"><bean:message key="leble.report.wholesalerselect" />:</font></font></strong></td>
			<td>
			<input type="radio" name="selected_Wholesaler" value="ALL" checked /><font face="Arial" size="2"><bean:message
				key="radio.report.allwholesaler" />&nbsp;&nbsp;&nbsp;</font>
			 <input	type="radio" name="selected_Wholesaler" value=" " /> 
			 <%--  <input type="radio" name="disb" value="true" onClick="DisBox(this,document.Distbox.txta)" checked/> --%>
			<input type="text" disabled  name="selected_Wholesaler" value="" size="28" />
			<input type="button" onClick="myPopup()" name ="search" value="...." /></td>
		</tr>
		<tr>
			<td bgcolor="skyblue">
			<p align="left"><strong><font face="Arial"><font
				size="2"><bean:message key="dropmenu.report.year" />:</font></font></strong></p>
			</td>
			<td><select name ="yearselection">
				<option value="2010" selected="selected"><bean:message
					key="report.2010" /></option>
				<option value="2011"><bean:message key="report.2011" /></option>
				<option value="2012"><bean:message key="report.2012" /></option>
				<option value="2013"><bean:message key="report.2013" /></option>
				<option value="2014"><bean:message key="report.2014" /></option>
				<option value="2015"><bean:message key="report.2015" /></option>
			</select></td>
			<%--   <td>
          <bean:define id="yearList"  name="grnForm"  property="yearList"/>
          <html:select name="grnForm" property="selected_Year" >
    	  <html:options collection="yearList" property="code" labelProperty="description"/>
   		  </html:select> 
   		 </td>  --%>
		</tr>

		<tr>
			<td align="left" bgcolor="skyblue"><strong><font
				face="Arial" size="2"><bean:message
				key="lable.report.producttype" />:</font></strong></td>
			<td>
			<input type="radio" name="producttype" value="MSD" /> <font
				face="Arial" size="2"><bean:message key="radio.report.MSD" />&nbsp;</font> 
			<input type="radio" name="producttype" value="Ex-Oganon" /><font
				face="Arial" size="2"><bean:message
				key="radio.report.Exorganon" /> &nbsp;</font>
			<input type="radio" name="producttype" value="Both" checked /><font face="Arial"
				size="2"><bean:message key="radio.report.bothproduct" /></font></td>
		</tr>

		<tr>
			<td align="left" bgcolor="skyblue"><strong><font
				face="Arial" size="2"><bean:message
				key="leble.report.totalsumflag" />:</font></strong></td>
			<td><input type="radio" name="totalsumflag"
				value="Onlyrelated" checked /><font face="Arial" size="2">
			<bean:message key="radio.report.onlyrelatedflag" /> &nbsp;</font> <input
				type="radio" name="totalsumflag" value="Both" /><font face="Arial"
				size="2"><bean:message key="radio.report.bothflag" /> &nbsp;</font></td>
		</tr>
	</table>
	</fieldset>

	<table border="0" width="50%" align="center">
		<tr>
			<td align="center" width="50%"><%-- <html:button property="download" ><bean:message key="report.download"/></html:button> --%>

			<%-- <a href="xlsSample.jsp" >convert XLS </a>   --%> <input
				type="button" onClick="downloadReport()"
				value="<bean:message key="button.report.download"/>" /></td>
		</tr>
	</table>
</form></fieldset>

</body>
</html:html>



2 Jsp 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:include page="/header.jsp" />
</body>
</html>

header.jsp

<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>¿¿¿¿¿¿</title>

<script type="text/javascript" src="ddtabmenufiles/ddtabmenu.js">
</script>


<link rel="stylesheet" type="text/css" href="ddtabmenufiles/ddcolortabs.css" />


<script type="text/javascript">
//SYNTAX: ddtabmenu.definemenu("tab_menu_id", integer OR "auto")
ddtabmenu.definemenu("ddtabs4",0);

</script>
</head>
<body>
<bean:message key="link.home.reportGeneration"/>

<div id="ddtabs4" class="ddcolortabs">
<ul>
<li><a href="#"><span>Home</span></a></li>
<li><a href="javascript:reportGeneration()"><span><bean:message key="link.home.reportGeneration"/></span></a></li>
<li><a href="javascript:manualInput()"><span><bean:message key="link.home.manualInput"/></span></a></li>
<li><a href="javascript:MDPSUpload()"><span><bean:message key="link.home.MDPSUpload"/></span></a></li>
<li><a href="javascript:ErrorDataCorrection()"><span><bean:message key="link.home.errorDataCorrection"/></span></a></li>
</ul>
</div>
<div class="ddcolortabsline">&nbsp;</div>
<br>
</br>
<br></br>
<div class="footerline">
<center>Copyright © 2010 <a href="buttonSample.jsp">Banyu</a>. All rights reserved.</center>
</div>

</body>

</html>

Open in new window

0
Comment
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 33423499
Well, you're lucky that either of them is working ;) The html would be wildly wrong, e.g. having two body tags (which is contained in the include)
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33423806
Ten how can be design the page?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33424044
Just make sure the included jsp doesn't contain tags that duplicate major page tags (e.g. body, head)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33424380
i can use <html></html> more than one html tag in a page right ?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 33424411
<%@ page language="java" contentType="text/html; charset=UTF-8"  
        pageEncoding="UTF-8" %>  
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>  
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>  
 
 
 
<jsp:include page="/header.jsp" />  
i put like this that time also its wont display y ??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33424642
>>i can use <html></html> more than one html tag in a page right ?

No. There should be only one
0
 
LVL 92

Expert Comment

by:objects
ID: 33425597
> i can use  more than one html tag in a page right ?

you should avoid it, biut it won't stop it displaying.
0
 
LVL 4

Expert Comment

by:ProgSysAdmin
ID: 33426655
I concur with objects.  

Below is what I would put as header.jsp.

You might want to consider another jsp:include for footer.jsp as the code for the footer which would be the same concept as the header.jsp.
header.jsp

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<bean:message key="link.home.reportGeneration"/>

<div id="ddtabs4" class="ddcolortabs">
<ul>
<li><a href="#"><span>Home</span></a></li>
<li><a href="javascript:reportGeneration()"><span><bean:message key="link.home.reportGeneration"/></span></a></li>
<li><a href="javascript:manualInput()"><span><bean:message key="link.home.manualInput"/></span></a></li>
<li><a href="javascript:MDPSUpload()"><span><bean:message key="link.home.MDPSUpload"/></span></a></li>
<li><a href="javascript:ErrorDataCorrection()"><span><bean:message key="link.home.errorDataCorrection"/></span></a></li>
</ul>
</div>
<div class="ddcolortabsline">&nbsp;</div>
<br>
</br>
<br></br>

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33426963
What displays will be dictated by the stylesheet and stylesheets are not designed to work with invalid html.

Just make sure that the root node in the include file is no more important than <div> (it almost certainly should *be* div) and you should be ok. Calling it 'header' implies that it should probably be included immediately after the opening <body> in the parent page
0
 
LVL 92

Expert Comment

by:objects
ID: 33426980
> . Calling it 'header' implies that it should probably be included immediately after the opening  in the parent page

header comes before the body
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33427008
>>header comes before the body

Nothing comes before body that's not metadata
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 0 total points
ID: 33448211
<link rel="stylesheet" type="text/css" href="../css/bioOrigin.css">
 
i change ../ or  in front i put request.contextpath() its working fine ..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33448317
Yes, a missing stylesheet would certainly do it ;)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question