简体   繁体   中英

Form Based Authentication with tomcat

I need to do form based authentication in struts1.3.10 + tomcat

As per my understanding once login credentials are submitted, container would cross-check credentials with tomcat-users.xml and based on that forward to success page or error page.

login.jsp

<form action="j_security_check" method="post">
    <input type="text" name="j_username"/>
    <input type="password" name="j_password"/>
    <input type="submit"/>
</form>

web.xml

<login-config>
    <form-login-check>
        <form-login-page>/login.jsp</form-login-page>
        <form-error-page>/error.jsp</form-error-page>
    </form-login-check>
</login-config>

Doubt:

if valid credentials are provided how server goes to success page ? since in login.jsp acion i have given as j_security_check not as normal action which forward to success page.

The authentication is provided by the the server, so you should not be concerned how the server is doing it. The requested resource URL is stored somewhere by the server, then directs you to the login page, if your login is successful the requested resource is returned.

When a user submits their name and password, the server determines if the user name and password are those of an authorized user and, if authorized, sends the requested web resource. If the topic of authentication is new to you, please refer to the section Specifying an Authentication Mechanism .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM