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 7692233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:48:23+00:00 2026-05-31T20:48:23+00:00

I am designing a secure login with JSP. I intend to use Form Authorization

  • 0

I am designing a secure login with JSP. I intend to use Form Authorization to access an application on a Websphere. The basic idea is that when internal, authenticated users in the domain accesses a page, it will be as per normal. However, should external users try to access it, it will direct them to a login page, interface with Active Directory, and redirect them to the page upon correct authentication.

In order to make it work, I have tried to modify Web.xml to allow form authentication with the built-in “j_security_check” servlet. Upon logging in, it will greet the user “Hello, !” with a simple function <% request.getRemoteUser() %> or <% request.getUserPrincipal().getName() %>.

Based on the examples found here, I modified my Web.xml details as below:

<welcome-file-list>
    <welcome-file>/protected/index.jsp</welcome-file>
</welcome-file-list>

<security-constraint>
    <web-resource-collection>
        <url-pattern>/protected/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
        <role-name>users</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.jsp</form-login-page>
        <form-error-page>/error.jsp</form-error-page>
    </form-login-config>
</login-config>

<security-role>
    <description>Administrator</description>
    <role-name>admin</role-name>
</security-role>
<security-role>
    <description>Users</description>
    <role-name>users</role-name>
</security-role>

Under my login.jsp, I have a simple form that does the logging in.

<form action="j_security_check" method="post">
    Username: <input type="text" name="j_username">
    Password: <input type="password" name="j_password">
    <input type="submit" value="Login">
</form>

Under my index.jsp, it greets the users with a simple request.

<body>
    Hello, <% request.getRemoteUser(); %>
    Hello, <% request.getUserPrincipal().getName(); %>
</body>

I am facing three issues here. Importance ranked as it is.

1) Error 403
The redirecting and logging in page works. When I try to access index.jsp, I am redirected to login.jsp. When I enter an incorrect uid:pwd pair, I am greeted with error.jsp. When I log in correctly, I am redirected back to index.jsp but I am greeted with an Error 403: The Website requires you to log in. I am sure I have logged in because I am previously unable to access the built-in snoop page, but after logging in, I can. I suspect it is some settings in my Web.xml

2) Getting the user’s ID
Even upon disabling all protection in the Web.xml and accessing the index.jsp, I am greeted with a “Hello, null!” instead of “Hello, user!“. The codes as shown in the index.jsp should be correct as I copied it out from snoop sample codes found on the internet. request.getRemoteUser() does not work on my index.jsp but works on the snoop page. There must be something I am not calling before performing the request?

3) Security (not important, yet)
I think this j_security_check is under Spring Security. I am trying to encrypt both the sending and the receiving side as well as the transport channel. This is because for authentication, I believe the password must not be sent or stored in clear text. I found some information here which led me to attempt/try to protect this process of authentication.

I would appreciate some guidance and help with regards to the top 3 issues I am facing. It feels like I am close to getting the thing done but it’s so close, yet so far…

  • 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-31T20:48:25+00:00Added an answer on May 31, 2026 at 8:48 pm

    In case anyone is wondering, the problem was easily solved with configurations.

    1) Assigning roles of Admin and User in Web.xml, one must go into Websphere > .war > Roles and Users > and physically assign the Admin and User roles to roles as specified in Active Directory. This will enable the user to access the page.

    2) Also with the Websphere configuration under SPNEGO Configurations, one must append to the list “|” to enable it so that request. Thereafter, authenticated users in the domain will access the item straight away, while external users will be redirected to a login page. The request.getPrincipalUser() now works.

    3) There is a Spring Security sample that works. The only problem is that it accesses a local Authentication-Provider in its ApplicationContextSecurity.xml instead of the Active Directory. To protect the channel, under <transport-guarantee>NONE</transport-guarantee>, the NONE should be replaced with CONFIDENTIAL.

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

Sidebar

Related Questions

I am designing the application in Flex that connects to some web services to
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with
While designing a table my colleague here says that I should avoid identity column
When designing a ASP.net WebForm application what are some important steps to take (or
I am designing a file syncing application (like DropBox). The client keeps a persistent
I'm designing a training program in C++ that will be distributed to a large
I'm currently designing a website that would involve storing a long list of names
When designing a web service that will allow the consumer of the service to
Well, I'm designing an online service that needs subscription in order to be used
Designing a simple HTML table that I am going to implement alternate-row coloring on...

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.