Home Jsp How to Display Username After Login in JSP
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

How to Display Username After Login in JSP

Advertisement
This tutorial you will learn how to Display the username and password after filling the login details in JSP.

How to Display Username After Login in JSP

In this section we will discuss how to display the Username and password after the successful login. In JSP it is a simple task to display the Login details just you have to create a html page in which username and password is created. So, when you submit the details the username and password will be displayed on the other page. Using request.getParameter() method you can retrieve the username and password from the login page.

Syntax :

<%= request.getParameter("name") %>

This method is provided by the interface ServletRequest which returns the value of a request parameter as a String, or null if the parameter does not exist. You can see in the given example that we prompt the user to enter the name and address in the provided text fields.

Example : First  of all we will create a Html page in which we have created two text box i.e. username and password and a submit button when user click on the submit button after filling username and password then using  request.getParameter("username") and request.getParameter("password") method login details will be fetched. Now, here is the code:

Login.html

 <html><head><body bgcolor="#E0C0C0">
<form action="login.jsp" method="POST">
<p>Username - <input type="text" name="userName"></p>
<p> Password - <input type="password" name="passWord"></p>
<p><input type="submit" value="Submit"></p>

</form></body></html>

Login.jsp

 <html><head><body bgcolor="#E0C0C0">
<form action="login.jsp" method="POST">
<p>Username - <input type="text" name="userName"></p>
<p> Password - <input type="password" name="passWord"></p>
<p><input type="submit" value="Submit"></p>

</form></body></html>

So, the Output will be as follows:

After filling the username and password the output will be as follows:

Download Source Code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 25, 2013

Ask Questions?    Discuss: How to Display Username After Login in JSP  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com