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 seal and protect my WAR file, especially the JSP/JSF from
I would like to load a jsp file from a servlet-class I got in
I would like to protect my git repository so only non master branches can
I have a back up copy of data that I would like to protect
I would like to start a personal project that will give me a lot
I would like to run a jar file extracted from my java project to
I would like to build a small python script that basicaly does the reverse
Given an existing JSP project, I would like to get a feel for the
I would like to protect a pdf document using Adobe Digital Edition. I think
I would like to create a web site with many images. But I would

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.