This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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?
wood burning stoves
subject: conditional login.jsp