Reputation: 199
I am trying to create a Login page using JSP.The first Jsp page collects the username and password, when login button is pressed the user is navigated to another JSP page.Here I want to display the username of the user.I wrote a code for it,but I am getting null as the value.Kindly tell me where I have gone wrong.The code is as follows
Login.jsp
<body>
<center>
<b>LOGIN PAGE</b><br>
</center>
<form name="login" method="post" action="HomePage.jsp">
<center>
USER NAME: <input type="text" name="username"> <br>
<br>
PASSWORD: <input type="password"> <br>
<br>
<input type="button" value="LOGIN" onclick="window.location.href='HomePage.jsp'">
</center>
</form>
</body>
And here is my HomePage.jsp
<body>
WELCOME
<%
String Uname=request.getParameter("username");
out.println(Uname);
%>
</body>
Upvotes: 0
Views: 113
Reputation: 1492
The form submission to the servlet can be done only by 2 ways, Submit using a input type ="Submit" or Using javascript submit() function needs to be called.
Upvotes: 0