Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7573793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:16:20+00:00 2026-05-30T16:16:20+00:00

I have a web app which runs in apache tomcat, I have used j_security_check

  • 0

I have a web app which runs in apache tomcat, I have used “j_security_check” to protect this application. My code are as follows,

login.jsp

<div id="loginForm">
    <form id="loginfrm" method="post" action="j_security_check">
        <table>
            <tr>
                <td>User Name</td>
                <td><input type="text" id="name" name="j_username" size="20" /></td>
            </tr>
            <tr>
                <td>Password</td>
                <td><input type="password" id="phone" name="j_password" size="20" /></td>
            </tr>
            <tr>
                <td></td>
                <td align="right"><input type="submit" value="Login" id="submitButton"></td>
            </tr>
        </table>
    </form>    
</div>

web.xml

<web-app ...>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>Example Form-Based Authentication Area</realm-name>
        <form-login-config>
            <form-login-page>/success.jsp</form-login-page>
            <form-error-page>/error.jsp</form-error-page>
        </form-login-config>
    </login-config>
</web-app>

Error page,

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Login ERROR!</h1>
    </body>
</html>

Success page

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Login Success</h1>
    </body>
</html>

Here when I give a wrong username and a wrong password, error page is showing successfully but when I give correct password and username it shows,

HTTP Status 400 - Invalid direct reference to form login page

type Status report

message Invalid direct reference to form login page

description The request sent by the client was syntactically incorrect (Invalid direct reference to form login page).
Apache Tomcat/7.0.22

please anyone could tell me where am I wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:16:21+00:00Added an answer on May 30, 2026 at 4:16 pm

    The line:

    <form-login-page>/success.jsp</form-login-page>
    

    in web.xml should actually be:

    <form-login-page>/login.jsp</form-login-page>
    

    This tells tomcat that whenever you reach a protected page the login form is locates in login.jsp. What is missing is the definition of the protected pages that actually need authentication to be seen:

    <security-constraint>
      <web-resource-collection>
        <web-resource-name>
          Entire Application
        </web-resource-name>
        <url-pattern>/success.jsp</url-pattern>
      </web-resource-collection>
      <auth-constraint>
        <role-name> 'the name of the group with access' </role-name>
      </auth-constraint>
    </security-constraint>
    

    And the definition of the realm, which is your repository for username / password pairs (tomcat realm).

    With these changes when you hit http://localhost:8080/succes.jsp you should be redirected to the login page, and upon a valid set of credentials be sent to /success.jsp and with a bad set of credentials to /error.jsp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a service for JIRA(a web application runs in tomcat) which runs
We have a web app which can upload files to S3. For this to
I have an asp.net application that runs on a custom app pool which runs
Greetings, I have a large .Net web app which runs on a farm of
This a bit of strange one.... We have an internal web app that runs
I have an HTML web-app which runs in a viewport. The web-app does not
i have python web app build on top of BaseHTTPServer, which runs on specyfic
I have a web app which runs on JSF 2.0 + Richfaces 3.3.3. Looks
I have an application solution which is made up of a web app written
I have a web app which connects to a server using a TCP connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.