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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:44:00+00:00 2026-05-16T10:44:00+00:00

I would like to protect a jsp page with a password that needs to

  • 0

I would like to protect a jsp page with a password that needs to be typed.

In apache i can add a password file to .htaccess but I don’t know how to do that in apache tomcat.

thanks

  • 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-16T10:44:01+00:00Added an answer on May 16, 2026 at 10:44 am

    So, you basically want to put HTTP BASIC authentication on the particular JSP page? Here’s a step by step:

    1. First you need to declare the desired rolename, username and password in /conf/tomcat-users.xml.

      <tomcat-users>
          <role rolename="yourrole"/>
          <user username="yourname" password="yourpass" roles="yourrole" />
      </tomcat-users>
      

      (you can append as many <role> and <user> entries as you want; if there are already existing entries, then you just add them inside <tomcat-users>).

    2. Then you need to declare the desired security constraint on the url-pattern of the JSP file along with a login config of BASIC (which stands for HTTP BASIC authentication).

      <security-constraint>
          <web-resource-collection>
              <web-resource-name>A JSP page</web-resource-name>
              <url-pattern>/page.jsp</url-pattern>
          </web-resource-collection>
          <auth-constraint>
              <role-name>yourrole</role-name>
          </auth-constraint>
      </security-constraint>
      <login-config>
          <auth-method>BASIC</auth-method>
      </login-config>
      

      The /page.jsp should match the context-relative URL of the JSP page. The yourrole should be the same as the rolename as definied in /conf/tomcat-users.xml.

    Restart the server, open the JSP page in the browser and use yourname and yourpass to login.

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

Sidebar

Related Questions

I would like to contribute to an open-source Windows Mobile project, but it's being
I have a project that I would like to start beta testing soon, it
The url would be something like this: www.example.com/index.php?file=myFile.ext The filtering would only allow leters
i would like to release a snapshot project 'foo-1.0-SNAPSHOT' using the maven release plugin.
I would like to create a C# project and implement the existing native (C++)
In a project I'm starting I would like to give privileges to users based
I would like to use Linq to query a bus schedule in my project,
I would like to create infrastructure to handle events for my opengl project. It
I would like to start learning ASP.NET on a for-fun project. I'm hoping to
I have a project where I would like to generate a report export in

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.