1

我的 HTML 登录页面

<html>  

    <head>  
        <title>FormBased Authentication Demo in WebLogic Sample</title>  
    </head>  

    <body bgcolor=maroon text=white>  
        <center>  
        <h2>Please Enter Your UserName & Password (FormBased Auth Example)</h2>  

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

        </center>  
    </body>  

</html>

j_security_check 类似于 weblogic 提供的用于实现 SQLAuthencticatoin 的 servlet。

现在我想从 servlet(我自己的自定义 servlet)中调用 j_security_check servlet,因为我需要在将其路由到 j_security_check 之前执行更多代码。谁能帮我吗 ?

4

1 回答 1

1

j_security_check is used in Form-Based Authentication. So you can just do a POST to the j_security_check with "j_username" and "j_password". Typically this is done on a JSP, but it could be done within a servlet as well. This part probably isn't news, but as it is a little unclear what your particular issue is, I would recommend that you check out filters and listeners. If you have some code that you want to run through prior to a particular servlet gets called or preforms a particular action, implementing a listener might just do the trick. Conversely, if you care about managing various things prior to a session getting created, perhaps a filter would be useful.

于 2014-09-13T06:58:58.277 回答