The moose likes JSP and the fly likes conditional login.jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "conditional login.jsp" Watch "conditional login.jsp" New topic

conditional login.jsp

Pavel Saratchev

Joined: Mar 12, 2007
Posts: 1

is it possible to make a condition for the jogin.jsp. If there are name='...' and password='...' in the query string from the Request and the both of them are not empty, than I want to run the j_securitycheck action automatically and not have to write the name and the password in the form. My login.jsp looks at the moment like this:


<form method="POST" action="j_security_check">
<!-- input fields -->
<td align="left">User Name:</td>
<td align="right"><input tabindex="1" type="text" name="j_username"></td>
<td align="left">Password:</td>
<td align="right"><input tabindex="2" type="password" name="j_password"></td>

<!-- Save/Reset buttons -->
<td colspan="2">
<input type="submit" name="save" value="Log in" />

<input type="reset" name="reset" value="Reset" />

Chakravarthy Gogineni

Joined: Nov 09, 2005
Posts: 10
You can write a javascript function to check for those fields before submitting the form. Which returns true if both the fields are not empty. You can call this function after Onclick event.

When Javascript function returns true, then only request is forwarded to the action.

onKlick, 'K' should be replaced with 'c. Had to write like that as this replying system is not letting to post and complaining about javascipt malicious content

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Do you really want to put someone's password in the querystring?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chakravarthy Gogineni

Joined: Nov 09, 2005
Posts: 10
Can you please explain what does it mean by putting password in query string?
I agree. Here's the link:
subject: conditional login.jsp
It's not a secret anymore!