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

  • Home
  • SEARCH
  • 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 8997223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:51:34+00:00 2026-06-15T23:51:34+00:00

Scenario: Security (access only via credentials) should be enabled for some servlets, but for

  • 0

Scenario:

Security (access only via credentials) should be enabled for some servlets, but for others not. All via web.xml.

  • 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-06-15T23:51:34+00:00Added an answer on June 15, 2026 at 11:51 pm

    This is how it’s done:

    First the security role + login config:

    <security-role>
      <description>
        Main user for admin GUI
      </description>
      <role-name>admin</role-name>
    </security-role>
    
    <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>my login</realm-name>
    </login-config>
    

    This servlet that should be accessed publicly:

    <servlet>
      <description>Landing Page for Admin GUI</description>
      <display-name>StartServlet</display-name>
      <servlet-name>StartServlet</servlet-name>
      <servlet-class>StartServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
      <servlet-name>StartServlet</servlet-name>
      <url-pattern>/index.html</url-pattern>
    </servlet-mapping>
    

    Restriction for all pages (only accessible via admin user):

    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Private</web-resource-name>
        <description>Matches all pages</description>
        <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <auth-constraint>
         <role-name>admin</role-name>
      </auth-constraint>
    </security-constraint>
    

    Public are only those:

    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Public</web-resource-name>
        <description>Makes the landing page explicitly public (overrides Private above since more specific!)</description>
        <url-pattern>/index.html</url-pattern>
      </web-resource-collection>
      <!-- No auth-constraint = everybody has access! -->
    </security-constraint>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this behavior should not be happening. Here's the scenario: Start a
Can anyone point to some code that deals with the security of files access
I'd like to use the ASP.NET membership provider in the following (low-security) scenario... My
Are there any security exploits that could occur in this scenario: eval(repr(unsanitized_user_input), {__builtins__: None},
I am attempting to verify the security of an application. The scenario is this:
Scenario first :- I'm using Entity Framework to do some queries, to build my
Just a sidenote : I'm not sure whether I should post this to serverfault
I need to automate web browsers in the following scenario : I have a
I have a scenario where I am trying to combine spring security with jersey
I need ammunition to try to promote WS-Security for a set of externally-available web

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.