Thursday, April 16, 2009

Exercises 3 lab 2

Write a program to retrieve the name and IP address of a remote computer.
Hint: Use the request implicit object to retrieve the values.

Solution:

The file used to run the application is IPAdd.jsp. The file is to be saved in C:\Tomcat 5.Webapps\basic directory.
<html>
<head>
<title>System Information</title>
</head>
<body>
<h3>Details of Remote Computer:</h3>
<b>Computer Name:</b>:
<br>
<%=request.getRemoteHost()%>
<br>
<br>
<b>IP Address:</b>:
<br>
<%=request.getRemoteAddr()%>
<br>
</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: