Login Module using Ajax

Index.jsp:-












Login.java:-
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Date;

public class Login extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();

String uname = request.getParameter("uname");
String pass = request.getParameter("pass");
try {
Thread.sleep(10000);
} catch(Exception e) {
e.printStackTrace();
}
if( uname.equals("JSM") && pass.equals("pass") ) {
out.write("OK");
} else {
out.write("Wrong Username / Password");
}
out.close();
}
}

Web.xml:-




Login
Login


Login
/Login




Home.html:-














Homepage





wait.gif:-