Login.java File
import javax.servlet.http.*;
import java.io.*;
public class Login extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
{
try
{
String username=request.getParameter("username");
String pass=request.getParameter("pass");
response.setContentType("text/html");
PrintWriter writer =response.getWriter();
writer.println("<html><body>");
writer.println("<h4> Thank You"+username+"your password is "+pass+"for log in");
writer.println("<br> <br> <b> UserName:"+username);
writer.println("<br> <br> <b> password:"+pass);
writer.println("</body><html>");
writer.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Login.html File
<HTML>
<Head>
<Title> Login Page </Title>
</Head>
<Body>
<Center>
<H1> Login Page</H1>
</Center>
<B> Please Enter Your User Name and Password
<Form action="http://localhost:8080/examples/servlet/Login" method=Post>
<p> <b> Username<input type="text" name="username" length=40>
<p> <b> Password <input type="text" name="pass" length=30>
<p> <input type="submit" value="submit">
</Form>
</Body>
</HTML>