Login form

Now for your confidence with JSP syntax, following example of login form will really help to understand jsp page.

Login form

Login Form with jsp

     

Now for your confidence with  JSP syntax, following example of login form will really help to understand jsp page. In this  example we will create a simple dynamic JSP page that prints the user information into next page.

With the help of this example we are going to show- how to display a logged-in information on to the browser. 

In this example it is very easy to display it on our browser with the help of java.util package. In this example we are going to insert the data in the login form which will be displayed onto the next page. 

This jsp program works with html tags in which there are two fields one is for name and the other one is for entering  password and there is a submit button, that works on clicking. 

The code the program is given below:

<html>
<head>
<title>Enter your name and password</title>
</head>
<body bgcolor="#999966">
<p>&nbsp;</p>
<form method="POST" action="loginaction.jsp">
<p><font color="#800000" size="5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Enter your name:</font><input type="text" name="username" size="20"></p>
<p><font color="#800000" size="5">
Enter your password:</font><input type="text" name="password" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>

Here is the code of "loginaction.jsp" file:

<%@page contentType="text/html" %>
<html>
<body bgcolor="#999966">
<p><font size="6">Welcome :&nbsp; 
<%=request.getParameter("username")%></font></p>
</body>
</html>

The output of the program is given below:

This is the output of the above input:

Download Source Code