Solution:
The file used in this exercise is Expression_Login.jsp. The file is saved in basic directory.
<html>
<head>
<title>Login Page</title>
</head>
<body bgcolor="white">
<%if(request.getParameter("userid")==null&& request.getParameter("password")==null ) { %>
<center>
<h2>Online Banking Login</h2>
</center>
<form method="GET" action="http://localhost:8080/basic/Login.jsp">
<b>User Id:</b> <input type="text" name="userid" size=15>
<p>
<b>Password:<b> <input type="password" name="password" size=8>
<p>
<input type="submit" value="LOGIN">
</form>
<% } else { %>
<%! String userid,password; %>
<%
userid = request.getParameter("userid");
password = request.getParameter("password");
%>
<% } %>
</body>
</html>
The output of the program is as shown in Figure 6.3.
2.Use the above code and greet the login user. Make use of the expression elements to display the message.
Solution:
The file used in this exercise is Login.jsp. The file is saved in basic directory.
<html>
<head>
<title>Login Page</title>
</head>
<body bgcolor="white">
<%if(request.getParameter("userid")==null&& request.getParameter("password")==null ) { %>
<center>
<h2>Online Banking Login</h2>
</center>
<form method="GET" action="http://localhost:8080/basic/Login.jsp">
<b>User Id:</b> <input type="text" name="userid" size=15>
<p>
<b>Password:<b> <input type="password" name="password" size=8>
<P>
<input type="submit" value="LOGIN">
</form>
<% } else { %>
<%! String userid,password; %>
<%
userid = request.getParameter("userid");
password = request.getParameter("password");
%>
<p>
<b>Good Morning!! <%= userid %><p></b>
<% } %>
</body>
</html>
The output of the program is as shown in Figure 6.4.
0 nhận xét:
Post a Comment