How to use External JSP files

Posted on 2006-05-12
Medium Priority
Last Modified: 2008-02-26

 I am workin on a Jsp and html based webfront end. My problem is that i have this menu that is in every .jsp page and pages are like 20. Now if i need to change something in the menu i have to go manually in every file or page to change it.
Is there any way that i write the code in one file and create a link of that file in other pages just like you do with
External CSS files. Below is my code.
<script type="text/javascript">
function lite(obj) {
if(document.all&&!window.opera) {


This is the code that is on my index page and i need this code to be placed in one file so that if i have to change any thing , i just need to change it from one file.

<div id="header">

                <img src="img/z.gif" width ="50" height="35" align ="left">
                <img src="img/b.gif"    width ="50" height="35" align ="right">
                <div id ="heading"> *********** </div>
       <div id="menubar">
                          <li><a href="index.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Home</a></li>
                          <li><a href="Volumetric.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Volumetrics</a></li>
                          <li><a href="kea.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Error Analysis</a></li>
                          <li><a href="graph.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Graphing</a></li>
                          <li><a href="scorecard.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Scorecard</a></li>
                          <li><a href="contacts.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Contact</a></li>
                          <li><a href="help.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Help</a></li>
                          <li><a href="credits.jsp" onmouseover="lite(this)" onmouseout="lite(this)">Credits</a></li>

Below is the code from the External CSS Sheets.

 width: 63em;
 background: #c0c0c0;

#menubar ul {

    margin: 0;
    padding: 0;
    list-style-type: none;

 #menubar li {
    margin: 1px 0 0;
   display: inline;

#menubar a {

padding: 5px 0px 10px 15px;
border: 3px solid white;
background: black;
text-decoration: none; /*lets remove the link underlines*/
color: white;
margin-left: -4;


 #menubar a:link,  #menubar a:active,  #menubar a:visited {
   font-size: 80%;
   font-family: lucida fax;
   font-weight: bold;
   color: white;

#menubar a:hover {
border: 1px solid #000000;
background: red;
color: white;

Please help asap
Question by:ammartahir1978

Accepted Solution

zawedikian earned 2000 total points
ID: 16667974
all you need to do is to cut the menu code, put it in a new html page.
Let s say that the new html page is called menu.html
then you go to your html or jsp pages and you write the following link in place of the menu code:

<!--#include file="menu.html"-->

try it. it should work


Author Comment

ID: 16682715
cheers zeina it works.Now i can just modify code in one page and every other pages gets updated accordingly.

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

621 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