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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
So, you basically want to put HTTP BASIC authentication on the particular JSP page? Here’s a step by step:
First you need to declare the desired rolename, username and password in
/conf/tomcat-users.xml.(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>).Then you need to declare the desired security constraint on the
url-patternof the JSP file along with a login config ofBASIC(which stands for HTTP BASIC authentication).The
/page.jspshould match the context-relative URL of the JSP page. Theyourroleshould 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
yournameandyourpassto login.