You are on page 1of 6

NAME: NiTiN SAINI

CLASS: MCA(3RD SEM)

ROLL NO: RTB903A06

REG. NO: 10903015

SUB. CODE: CAP 305

Home work-03

CAP305: WEB PROGRAMMING

Part-A

Q1. Write an ASP application that displays the multiplication table from 5 × 1 to 5 × 15.

Ans:- <html>

<head><title> table of 5</title></head>

<body>

<%

dim i

dim b

for i=1 to 15

b=5*i

response.write(“5”)

response.write(“*”)
response.write(i)

response.write(“=”)

response.write(“b”)

%>

</body>

</html>

Q2. Write an ASP application that uses cookies to store data of a visitor when it visitor the
website of a Hotel.

Ans: -

<%
dim numvisits
response.cookies("NumVisits").Expires=date+365 
numvisits=request.cookies("NumVisits")

if numvisits="" then
   response.cookies("NumVisits")=1
   response.write("Welcome! Web page.")
else
   response.cookies("NumVisits")=numvisits+1
   response.write("You have visited this ")
   response.write("Web page " & numvisits)
   if numvisits=1 then
     response.write " time before!"
   else
     response.write " times before!"
   end if
end if
%>
<html>
<body>
</body>
</html>

Q3 Write an Web application for a College showing usage of caching.

Ans: -
<html>

<head>

<title>caching</title>

</head>

<body>

<%

Response.CacheControl =”anc”

%>

<%

Application(“Name”) = ”Sandeep”

Application(“reg. no”) = “9027246935”

Application(“roll no.”) = “RTB903C09”

For each x in Application.Contents

Response.Write(x& “=” &Application.Contents(x)& “<br>”)

next

%>

Part-B

Q4. Write an ASP script that displays the domain name of the Web server & full pathname of
the ASP script.

Ans:

<html>
<body>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("server_name"))%>
</p>
</body>
</html>

Q5. Build an ASP application that uses the Calendar ActiveX control to get a valid date from
the user.

Ans:

<html>
<body>

Today's date is: <%response.write(date())%>.


<br />
The server's local time is: <%response.write(time())%>.

</body>
</html>

o/p:

Today's date is: 12/08/2012. 


The server's local time is: 4:15:07 PM.

Q6. Write an ASP script that displays the IP address of the Web browser.

Ans:
<html>
<body>
<p>
<b>You are browsing this site with:</b>
<%Response.Write(Request.ServerVariables("http_user_agent"))%>
</p>
<p>
<b>Your IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_addr"))%>
</p>
<p>
<b>The DNS lookup of the IP address is:</b>
<%Response.Write(Request.ServerVariables("remote_host"))%>
</p>
<p>
<b>The method used to call the page:</b>
<%Response.Write(Request.ServerVariables("request_method"))%>
</p>
<p>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("server_name"))%>
</p>
<p>
<b>The server's port:</b>
<%Response.Write(Request.ServerVariables("server_port"))%>
</p>
<p>
<b>The server's software:</b>
<%Response.Write(Request.ServerVariables("server_software"))%>
</p>

</body>
</html>

o/p:

Your IP address is: 236.282.79.11

The DNS lookup of the IP address is: 115.248.98.27

The method used to call the page: GET

The server's domain name: HTTP:\\LOCALHOST\nit.ASP

The server's port: 64


The server's software: Microsoft-IIS/6.0

You might also like