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>

Comments

  1. Excellent and informative article! The concepts are explained very clearly and are helpful for anyone looking to build strong programming skills. For learners searching for practical and career-oriented training, the Best Java Real Time Projects Online Training in Hyderabad is a great opportunity to gain real-time project experience and industry exposure. Thanks for sharing such valuable content!

    ReplyDelete

Post a Comment

Popular posts from this blog

Create a JSP page to accept a number from an user and display it in words: Example: 123 – One Two Three. The output should be in red color.

Write a SERVLET application to accept username and password, search them into database, if found then display appropriate message on the browser otherwise display error message.

Write a JSP program to accept the details of Account (ANo, Type, Bal) and store it into database and display it in tabular form. (Use PreparedStatement interface)