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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:53:12+00:00 2026-06-06T09:53:12+00:00

I have a web application with two servlets and multiple mappings associated with each

  • 0

I have a web application with two servlets and multiple mappings associated with each servlet, i.e.

web.xml:

<servlet-mapping>
    <servlet-name>cheese</servlet-name>
    <url-pattern>/edam/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>cheese</servlet-name>
    <url-pattern>/cheddar/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>dog</servlet-name>
    <url-pattern>/poodle/*</url-pattern>
</servlet-mapping>
...

I would now like to apply Spring Security to this web application, with a different security configuration for each servlet. This is because the servlets have different authentication requirements. As such, I would expect just two filter mappings:

<filter-mapping>
    <filter-name>springSecurityFilterChainCheese</filter-name>
    <servlet-name>cheese</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>springSecurityFilterChainDog</filter-name>
    <servlet-name>dog</servlet-name>
</filter-mapping>

Using Spring Security 3.1, I am able to define multiple <http> elements, which looks like a good way to go. However, I cannot see how to specify a bean name for each <http> element or any other way of mapping the element to a servlet.

I know that I can specify a pattern attribute on <http>, but I would then need to repeat the servlet-to-URL mapping in my Spring Security configuration, which isn’t DRY.

How can I map an <http> element to a specific servlet like this? Or will I need to expand out the <http> element and define all of my Spring Security beans myself?

  • 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-06T09:53:14+00:00Added an answer on June 6, 2026 at 9:53 am

    Looking at the source code for Spring Security, it appears as though this could be possible by providing an id or name on the <http> element, but the Spring Security XML schema prevents this! I’ve raised https://jira.springsource.org/browse/SEC-1978 accordingly.

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

Sidebar

Related Questions

I have a Java Web application that has several servlets with the following mappings.
I have servlet in my web.xml but i don't want my application to load
I have a web application which has two servlets that exchange information through context
I have a web application and two class files, First class is MyClass.class which
I have a web application containing two web services, let's say PublicHello.asmx and RestrictedHello.asmx
The issue at hand is this. We have a web application with two different
I have two web application projects (project A and project B) in the same
I have a web application that uses two databases. DB1 Users perform their CRUD
We have a web application where you can access two services/functions (Buy and Rent).
I have two web applications (A) and (B). (A) is my primary web application.

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.