Thursday, April 16, 2009

Exercises 2 lab 2

Write a program that uses the response.setHeader()method to display the date. In addition, set the response header attribute and utilize the JSP expression tag.

Solution:
1. The file required to run the application is Date.jsp. The file is to be saved in C:\Tomcat 5.5\Webapps\basic directory.
//Date.jsp
<html>
<head>
<title>Example of JSP Implicit Object</title>
<%@ page import="java.util.Date" %>
</head>
<body bgcolor=#ffffff>
<font color="Black">
<h2> This example gives the Current Date </h2>
<h3>
<% response.setHeader("Refresh", "6"); %>
Current date: <%= new Date() %>.
</h3>
</body>
</html>

The output of the program is as shown in Figure 4.4.

Figure 4.4: Output of IPAdd.jsp

0 nhận xét: