//Login Page Validation using "getInitParameterNames()" method
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Validation1 extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
Enumeration params=getServletConfig().getInitparameterNames();
String name=request.getParameter("username");
String pass=request.getParameter("password");
String pass1=" ";
while(params.hasMoreElements())
{
String name1=(String)params.nextElement();
if(name1.equals(name)
{
pass1=(string)getServletConfig().getInitParameter(name1);
if(pass1.equals(pass))
{
pw.println("<h1>WELCOME TO BOOK SHOP" + name1 +"<h1>");
break;
}
else
{
pw.println("YOU ARE INVALID USER");
break;
}
}
}
if(pass1=="")
pw.println("YOU ARE INVALID USER");
}
}
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Validation1 extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
Enumeration params=getServletConfig().getInitparameterNames();
String name=request.getParameter("username");
String pass=request.getParameter("password");
String pass1=" ";
while(params.hasMoreElements())
{
String name1=(String)params.nextElement();
if(name1.equals(name)
{
pass1=(string)getServletConfig().getInitParameter(name1);
if(pass1.equals(pass))
{
pw.println("<h1>WELCOME TO BOOK SHOP" + name1 +"<h1>");
break;
}
else
{
pw.println("YOU ARE INVALID USER");
break;
}
}
}
if(pass1=="")
pw.println("YOU ARE INVALID USER");
}
}
No comments:
Post a Comment