Hello All,
I have been developing a website that has a secure area. At the beginning of the secure page I wrote a scriptlet to check whether the user is logged in. I want to take this scriplet and put it in a javabean. Could any of you guys suggest a way of doing this?
String clientIP = request.getRemoteAddr(); //get remote address
String clientHost = request.getRemoteHost(); //get client host
int hashVal = (request.getRemoteAddr() + request.getRemoteHost()).hashCode(); //create hash
if(session.getAttribute("hsh") != null){ //hash was not created for this session..
if(Integer.parseInt(session.getAttribute("hsh").toString()) != hashVal){ //hashes should be the same
response.sendRedirect("./login_page.jsp?error=2"); //the hashes dont match up (not the same user)
} else {
}
} else {
response.sendRedirect("./login_page.jsp?error=1");
}