0

While run index.jsp then it must check by method POST of servlet and task must be go further. But while I'm trying, it doesn't do what it should be. Executing servlet can perform this task, but if execute index.jsp it shown error.jsp as entered wrong credentials but can't perform action by POST method. Page rendering back to index.jsp.
Why it so?

index.jsp

  <form method="POST" action="j_security_check">
        <table cellpadding="0" cellspasing="0" border="0">
            <tr>
                <td align="right">Username:&nbsp;</td>
                <td>
                    <input type="text" name="j_username">
                </td>
            </tr>
            <tr>
                <td align="right">Password:&nbsp;</td>
                <td>
                    <input type="password" name="j_password">
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Login"</td>
            </tr>
        </table>
    </form>

error.jsp

<title>Login Error</title>
</head>
<body>
    There was an error logging in. Please try again.
</body>

ControllerServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
response.getWriter().println("Welcome");
  • 1
    The server doesn't provide the controller....how do you expect it to guess that it should it trigger a redirect to admin.jsp? – unwichtich Mar 24 '17 at 14:19
  • @unwichtich See I've facing this now. Server does not provide controller but it provides predefined names j_username and j_password to authenticate. So how about problem I'm facing now? –  Mar 26 '17 at 15:46

0 Answers0