What's  a Java Server Page?
Home ] Up ] [ What's  a Java Server Page? ] How Does a JSP Work? ] Do JSPs Replace Servlets? ] JSP Expressions vs. Scriplets ] Conditional JSPs ] JSP Declarations ] A JSP Hit Counter ]

 

 

A JSP is an HTML page with some embedded Java code.

Here's a very simple example:

<!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>A Simple JSP</title>
    </head>
    <body>

    <h1>Greetings!</h1>
    <p>This is a 'Hello!' from <i><%= request.getParameter("name") %></i>.</p>
    <p>How are you today?</p>
      
    </body>
</html>

When you invoke this JSP without a query string, here's what it produces:

However, if you invoke it with an appropriate query string, it gives you:

 
The page was last updated February 19, 2008