Difference between revisions of "Password protecting pages"
From MyWiki
Line 1: | Line 1: | ||
A working example from GetNewUser, needs improving :<br> | A working example from GetNewUser, needs improving :<br> | ||
− | 1. Look up the session information | + | 1. Look up the session information, if the session table is empty then redirect to the login page. |
<source lang="java"> | <source lang="java"> | ||
String getIt = "SELECT user from sessions where session = '"+session.getId()+"'"; | String getIt = "SELECT user from sessions where session = '"+session.getId()+"'"; |
Revision as of 10:04, 4 November 2014
A working example from GetNewUser, needs improving :
1. Look up the session information, if the session table is empty then redirect to the login page.
String getIt = "SELECT user from sessions where session = '"+session.getId()+"'"; stmt = conn.createStatement(); rs = stmt.executeQuery(getIt); if ( rs.next() ) { USERNAME = rs.getString("user") ; out.println("Your username is : "+USERNAME); int length = USERNAME.length(); } else response.sendRedirect("login.jsp");