AIM
Create and save an XML document at the server. Which contains user information or
Program To Implement Loginform Using Sevlets
PROGRAM
filename:Usevalidation.html
<html>
<head>
<title>Login Form</title>
</head>
<body leftmargin=75 topmargin=75 bgcolor=white>
<form method=Get action="http:127.0.0.1:8080\validation">
UserName <input type=text name=user>
<br><br>
Password <input type=password name=pass>
<br><br>
<input type=submit value=submit>
<input type=reset name=cancel>
</form>
</body>
</html>
---------------------------------------------------------------------
filename:UserValid.java
---------------------------------------------------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class UserValid extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String usr=res.getParameter("user");
String pwd=res.getParameter("pass");
if(usr equals("naveen")&&pwd equals("nav")
out.println("Successfully Logged in");
else
out.println("Unsuccessful");
}
}
-------------------------------------------------------------------------
filename:web.xml
------------------------------------------------------------------------
<web-app>
<servlet>
<servlet-name>UserValidation</servlet-name>
<servlet-class>UserValid</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserValidation</servlet-name>
<url-pattern>/validation/*</url-pattern>
</servlet-mapping>
</web-app>
------------------------------------------------------------
No comments:
Post a Comment