public void service(HttpServletRequest hreq,HttpServletResponse hres)
{
try
{
//System.out.println("does requested session is valid:"+hreq.isRequestedSessionIdValid());
if(hreq.isRequestedSessionIdValid())
{
HttpSession hss=hreq.getSession(true);
if(!hss.isNew())
hss.invalidate();
}
String lmail=hreq.getParameter("lmail");
String lpword=hreq.getParameter("lpword");
HttpSession hs=hreq.getSession(true);
PrintWriter pw=hres.getWriter();

if(lmail!=null&&lpword!=null)
{
PreparedStatement pstmt=con.prepareStatement("select * from userdbs where mail=? and pword=?");
pstmt.setString(1,lmail);
pstmt.setString(2,lpword);
System.out.println("Entered mail:"+lmail);
System.out.println("Entered pword:"+lpword);
ResultSet rs=pstmt.executeQuery();
if(rs.next())
{
pw.println("Welcome Mr/Ms:"+rs.getString(2));
hs.setAttribute("uids",""+rs.getInt(1));
hs.setAttribute("uname",rs.getString(2));
String s=hres.encodeURL("homeurl");
hres.sendRedirect(s);
}
else
{
String url=hreq.getContextPath()+"/contact.html";
hres.sendRedirect(url);
}
}
else
hres.sendRedirect(hres.encodeURL("invalidurl"));
}
catch(Exception e)
{
System.out.println(e);
try{
String sr=hres.encodeURL("errorurl");
hres.sendRedirect(sr);
}
catch(Exception e2)
{System.out.println(e2);}

}


}