java - How to programatically login to j_security_check -
i have jsp web application uses j_security_check
. possible login specific user j_security_check
programatically via jsp page if know userid , password? tried pass variables url parameters way...
response.sendredirect(www.mydomain.com/j_security_check?j_username=someusername&j_password=somepassword )
...but doesnt work. there way it?
edit: here login page works fine right now. trimmed of code security reasons.
<form name="signon" method="post" action="/j_security_check"> <table width="100%" cellpadding="4" cellspacing="0"> <tr> <td valign="top" colspan="4"> <h2><%= ui.tr(null, "login_details") %> </h2> </td> </tr> <tr> <td valign="top" width="150px"> <%= ui.tr(null, "login_id") %> </td> <td valign="top" width="150px"> <%= ui.tr(null, "login_pass") %> </td> <td valign="top" width="150px"> <%= ui.tr(null, "login_token_or_captcha") %> </td> <td width="100%"> </td> </tr> <tr> <% if (logins == null) { %> <td> <input type="hidden" name="j_uri" value="/index.jsp"> <input type="text" id="username" name="j_username" size="16" style="width: 150px;" autocomplete="off" <%= username == null ? "" : "disabled value='" + username + "'" %> onblur="return checkcaptcha();"> </td> <% } else { %> <td> <select name="j_username" style="width: 150px;"> <% (login login : logins) { %> <option><%= login.getusername() %> </option> <% } %> </select> </td> <% } %> <td><input type="password" name="j_password" size="16" style="width: 150px;"> </td> <td><input type="text" id="mypw" name="mypw" size="16" autocomplete="off" style="width: 150px;"></td> <td><input class="submit" type="submit" name="submit" value="<%= ui.tr(null, "login_submit") %>"></td> </tr> <tr> <td valign="top" colspan="4"> <%-- <% if("registry.nic.hn".equals(request.getservername())) { %> <!-- garth - put whatever want here .hn --> <% } else { %> --%> <h2><%= ui.tr(null, "login_news") %> </h2> <div><%= htmlformat.addbreaks(siteconf.getsiteconf().getnews()) %> </div> <%-- <% } %> --%> </td> </tr>
the following code works me in jsp file:
string url = "j_security_check?j_username=" + username + "&j_password=" + password; string redirecturl = response.encoderedirecturl(url); response.sendredirect(redirecturl);
Comments
Post a Comment