O
onewebclick
need to implement "remember my password " simiar to one in google or
any other website where the site would allow to let the user log in
without asking for credentials. iam using tomcat 5.0.18, JDBCRealm.
i got some idea that i might have to store the userid/password in the
cookie probaly encrypted (not sure whether encryotion needed or not ).
The thing is iam not sure when is should set the cookie , beucase once
the user gets authenticated successfully the next page that its
forwarded to is not getting the paramters of j_username and j_password
it seems like the j_security_check seems to clear the parameters after
the request is made to it.
i can get the j_username using request.getRemoteUSer() but not sure how
to get the password once authenticated ?
also i have a signin page ; when i use response.sendRedirect() it seems
to work but if i use RequestDispatcher to forward it doesn;t seems to .
<%
Cookie[] cookies=request.getCookies();
String jusername=null;
String jpassword=null;
for (int i=0;i<cookies.length;i++) {
if (cookies.getName().equals("j_username"))
jusername=cookies.getValue();
if (cookies.getName().equals("j_password"))
jpassword=cookies.getValue();
}
if ((jusername !=null) && (jpassword != null)) {
//this doesn't work
RequestDispatcher
r=pageContext.getServletContext().getRequestDispatcher("/webclickswebapp/j_security_check?j_username="+jusername+"&j_password="+jpassword");
r.forward(request,response);
//this works
response.sendRedirect("/webclickswebapp/j_security_check?j_username="+jusername+"&j_password="+jpassword);//
works
}
any help or any easyway to implement , let me know will be appreciated.
i googled a lot about htis topic everytime i hit a dead end without
gettting a clear idea on how to do it.
Reply
any other website where the site would allow to let the user log in
without asking for credentials. iam using tomcat 5.0.18, JDBCRealm.
i got some idea that i might have to store the userid/password in the
cookie probaly encrypted (not sure whether encryotion needed or not ).
The thing is iam not sure when is should set the cookie , beucase once
the user gets authenticated successfully the next page that its
forwarded to is not getting the paramters of j_username and j_password
it seems like the j_security_check seems to clear the parameters after
the request is made to it.
i can get the j_username using request.getRemoteUSer() but not sure how
to get the password once authenticated ?
also i have a signin page ; when i use response.sendRedirect() it seems
to work but if i use RequestDispatcher to forward it doesn;t seems to .
<%
Cookie[] cookies=request.getCookies();
String jusername=null;
String jpassword=null;
for (int i=0;i<cookies.length;i++) {
if (cookies.getName().equals("j_username"))
jusername=cookies.getValue();
if (cookies.getName().equals("j_password"))
jpassword=cookies.getValue();
}
if ((jusername !=null) && (jpassword != null)) {
//this doesn't work
RequestDispatcher
r=pageContext.getServletContext().getRequestDispatcher("/webclickswebapp/j_security_check?j_username="+jusername+"&j_password="+jpassword");
r.forward(request,response);
//this works
response.sendRedirect("/webclickswebapp/j_security_check?j_username="+jusername+"&j_password="+jpassword);//
works
}
any help or any easyway to implement , let me know will be appreciated.
i googled a lot about htis topic everytime i hit a dead end without
gettting a clear idea on how to do it.
Reply