JSP Example3
JSP Example3
A JSP page is basically a web page with traditional HTML and bits of Java code. The
file extension of a JSP page is ".jsp" rather than ".html" or ".htm", and that tells the
server that this page requires special handling that will be accomplished by a server
extension or a plug-in. Here is a simple example:
Sample 1: date.jsp
Copy
Copied to Clipboard
Error: Could not Copy
<HTML>
<HEAD>
<TITLE>JSP Example</TITLE>
</HEAD>
<BODY BGCOLOR="ffffcc">
<CENTER>
<H2>Date and Time</H2>
<%
java.util.Date today = new java.util.Date();
out.println("Today's date is: "+today);
%>
</CENTER>
</BODY>
</HTML>
This example contains traditional HTML and some Java code. The tag <% identifies the
beginning of a scriptlet, and the %> tag identifies the end of a scriptlet. When date.jsp is
requested from a web browser, you see something similar to Figure 1.