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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:19:28+00:00 2026-06-05T08:19:28+00:00

I have a Java web app which consists of a variety of a servlets

  • 0

I have a Java web app which consists of a variety of a servlets and JSPs — examples: controller servlet /controller?abc=123&xyz=567, some other servlets /showDocument?docid=55, and some direct access to JSPs, /userDetails.jsp.

I have enabled web security to prevent access to all (shown below) and I have a login.jsp page that links to a css file /styles.css.

When I access any URL, I am redirected to the login.jsp page.

The problems are:

(1) no CSS stylings are used on the login page, probably because the styles.css is considered a protected resource and I’m not logged in yet.

(2) After successfully logging in with username and password, I am directed to the style.css file (which displays in the browser as plain text). I’m guessing this is because the LINK to the css file is considered to be the most recently protected resource requested, so it assumes that’s where I want to go.

If I copy and paste the CSS content in my JSP, both problems go away but then I have the CSS in two places, the style.css and also in the login.jsp.

How do I fix this? Is there a way for me to ‘white list’ *.css files so they are not protected. Do I have to define a different security constraint for the specific types I want to protect?

Here’s my current security constraints from my web.xml:

<security-constraint>
  <display-name>name</display-name>
  <web-resource-collection>  
    <web-resource-name>Restricted</web-resource-name>
    <url-pattern>/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>APP_USER</role-name>
  </auth-constraint>
  <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>

This is how I’m linking to the CSS in my JSPs:

<head>
  <LINK REL=StyleSheet HREF="styles.css" TYPE="text/css" MEDIA="screen" />
</head>

Any help is greatly appreciated!

Rob

  • 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-05T08:19:29+00:00Added an answer on June 5, 2026 at 8:19 am

    You can disable security for css and images after you have secured everything

    <security-constraint>
      <display-name>name</display-name>
      <web-resource-collection>  
        <web-resource-name>Restricted</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
      </web-resource-collection>
      <auth-constraint>
        <role-name>APP_USER</role-name>
      </auth-constraint>
      <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
      </user-data-constraint>
    </security-constraint>
    <security-constraint><!--Exclude css and images here -->
       <web-resource-collection>
          <web-resource-name>Exclude from Security</web-resource-name>
          <url-pattern>/images/*</url-pattern><!-- No security for images -->
          <url-pattern>/css/*</url-pattern><!-- No security for css -->
       </web-resource-collection>
    </security-constraint>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a primary Java Web App Project which houses some Servlets, JSPs
I have a web app built on Java Servlet technology. I am thinking of
I've done lots of java web development using jsps and servlets, and I have
Hello I am a Java web app developer I have a problem, I would
We have a Java EE-based web application running on a Glassfish app server cluster.
Background: I have created a CRUD web app using a java based RAD tool
I have a simple JSF web app as follows. The Java class contains: private
I have a Java web app that I develop on a Windows machine and
I have a java web app that makes back-end use of a third-party web
I have a web app which orders stuff using a timestamp, which is just

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.