mcddewitt 0 Newbie Poster

Hello I am learning JSP authentication and am having issues. I think my code for this simple test looks pretty good but everytime I try to login I get my login error page:

web.xml

<!-- Define security roles -->
    <security-role>
        <description>administrator</description>
        <role-name>administrator</role-name>
    </security-role>


    <!-- Restrict access to all files in the /admin folder -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protected Area</web-resource-name>
            <url-pattern>/admin/*</url-pattern>
        </web-resource-collection>
        <!-- Authorize the programmer and service roles -->
        <auth-constraint>
            <role-name>administrator</role-name>

        </auth-constraint>
    </security-constraint>

    <!-- Use form-based authentication -->
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/admin/login.html</form-login-page>
            <form-error-page>/admin/login_error.html</form-error-page>
        </form-login-config>
    </login-config>

Login Page:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login Page</title>
    </head>
    <body>
        <h1>Please Login:</h1>

        <form action = "j_security_check" method = "post">
            <table cellspacing="5" border="0">
                <tr>
                    <td align = "right">Username:</td>
                    <td><input type="text" name="j_username"</td>
                </tr>
                <tr>
                    <td align = "right">Password:</td>
                    <td><input type="password" name="j_password"</td>
                </tr>
                <tr>
                    <td></td>
                   <td><input type="submit" value="Submit"></td>
                </tr>
            </table>

        </form>
    </body>
</html>

Tomcat-Users.xml

<tomcat-users>

    <role rolename="manager" />
    <user username="admin" password="admin" roles="manager"/>

    <role rolename="programmer" />
    <user username="admin" password="admin" roles="programmer"/>

    <role rolename="administrator" />
    <user username="admin" password="admin" roles="administrator"/>




</tomcat-users>

Please note I did try to login into the TomCat manager page and it wouldnt take the admin/admin. I am wondering if I messed something up in my tomcat-users.xml or screwed something else up???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.