Computer Science Department, Bucknell University

CSCI 476 Senior Design Project
JavaServer Pages (JSP)
Spring, 2005

Those Teams who are designing a web-based application should consider Java Servlets and/or JSP (Java Server Pages) as possible ways to implement your projects.

Java Servlets are Java programs that act like CGI (Common Gateway Interface) scripts. When a servlet is called by a URL in a web-browser, the Java program dynamically generates HTML code that is displayed by the web browser. This is similar to CGI Perl scripts that you may have encountered. The advantages of servlets is that they execute much faster than Perl scripts and you have the power and features of Java and its extensive API at your disposal.

Java Server Pages (JSP) is Sun Microsystems' answer to Microsoft's ASP (Active Server Pages). JSP is Java code embedded as tags in the HTML (XHTML) much like PHP. JSP is easier to use than Java Servlets especially if you are a web-page designer who most of time wants to present static text with HTML or XHTML and incorporate only a few dynamically generated features. [By the way if you don't know XHTML (Extended HTML), you can easily learn it by reading the two chapters on the CD that comes with our Java text, "Java: How to Program" by Deitel and Deitel,sixth edition.]

A good reference on Java Servlets is Chapter 26 in our Java text. Chapter 27 is a good reference on JSP. Note that since JSP generates servlets, you need to read sections of Chapter 26 before using JSP.

In order to use Java servlets and/or JSP you need to run a tomcat server. If you have a PC, you can download tomcat for free. A copy of Windows-based tomcat is on the CD that comes with the sixth edition of Java Text.

I asked ECST to install a tomcat on the Suns so I could play with servlets and JSP. Point your browser at

to see the standard startup page and documentation that comes with the recent version of tomcat. Note that some links are password protected. Try the JSP and Servlet examples.

To try a JSP program that I wrote, point your browser at

Below is the JSP code for the clock example to provide you a flavor of JSP.

<?xml version = "1.0"?>
<!DOCTYPDE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"

<html xmlns = "">
    <meta http-equiv = "refresh" content = "60" />
    <title>A Simple JSP Example</title>
    <style type = "text/css">
       .big { font-family: helvetica, arial, sans-serif;
              font-weight: bold;
              font-size: 3em;}
     <p class = "big">Simple JSP example based on example<br>
from <i>Java: How to Program</i> <br>
by Deitel and Deitel, 6th edition,
    page 1283.<br>
Time and date is refreshed every 60 seconds.
     <table style = "border: 6px outset;">
         <td style = "background-color: black;">
           <p class = "big" style = "color: cyan;">
            <!-- JSP expression to insert time and date -->
	         <%= new java.util.Date() %>

Additional notes added as semester continues.

Page maintained by Dan Hyde, hyde at Last update January 26, 2005
Back to CSCI 475's home page.