Write a JSP script to accept UserName and his NickName through html page and then displays username when visit count to page is odd and displays nickname when the visit count to the page is even.
VisitPage.html
<html>
<body>
<form method=get action="VisitPage.jsp">
Enter User Name : <input type=text name=uname><br><br>
Enter Nick Name : <input type=text name=nname><br><br>
<input type=submit value="visit">
</form>
<body>
</html>
VisitPage.jsp
<html>
<body>
<%!
int cnt=0;
String uname,nname;
%>
<%
uname=request.getParameter("uname");
nname=request.getParameter("nname");
cnt++;
if(cnt%2==0)
out.println("Hello "+nname+"......... Visit Count "+cnt);
else
out.println("Hello "+uname+"......... Visit Count "+cnt);
%>
<br><br>
<a href="VisitPage.html">VISIT</a>
</body>
</html>
<html>
<body>
<form method=get action="VisitPage.jsp">
Enter User Name : <input type=text name=uname><br><br>
Enter Nick Name : <input type=text name=nname><br><br>
<input type=submit value="visit">
</form>
<body>
</html>
VisitPage.jsp
<html>
<body>
<%!
int cnt=0;
String uname,nname;
%>
<%
uname=request.getParameter("uname");
nname=request.getParameter("nname");
cnt++;
if(cnt%2==0)
out.println("Hello "+nname+"......... Visit Count "+cnt);
else
out.println("Hello "+uname+"......... Visit Count "+cnt);
%>
<br><br>
<a href="VisitPage.html">VISIT</a>
</body>
</html>
Comments
Post a Comment