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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:34:29+00:00 2026-06-03T05:34:29+00:00

Currently it secures the jsp pages and can display them BUT the REST endpoints

  • 0

Currently it secures the jsp pages and can display them BUT the REST endpoints CAN NOT be found (404 for all rest AJAX Calls). I have done other things to change it were it finds the rest endpoints, but then the HTML cant be found and the security checks arent being performed.

What am I missing?

security.xml

<beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http pattern="/images/**" security="none"/>
    <http pattern="/css/**" security="none"/>
    <http pattern="/js/**" security="none"/>
    <http auto-config="true" disable-url-rewriting="true">
         <intercept-url pattern="/login-page.html" access="ROLE_ANONYMOUS"/>
         <intercept-url pattern="/**" access="ROLE_USER, ROLE_ADMIN" />
        <form-login login-page='/login-page.html' default-target-url="/static-page.jsp" />
    </http>
    <authentication-manager>
        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource"
                users-by-username-query="select USERNAME, PASSWORD, ENABLED 
                    from USERS where USERNAME=?" 
                authorities-by-username-query="
                    select U.USERNAME, UR.AUTHORITY from USERS U, ROLES UR 
                    where U.USERNAME=UR.USERNAME and U.USERNAME=?"      
            />
        </authentication-provider>
    </authentication-manager>
</beans:beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:server-context.xml, classpath:spring-security.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>jersey-servlet</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>service.admin</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey-servlet</servlet-name>
        <url-pattern>/test-app/*</url-pattern>
    </servlet-mapping>
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

Under webapp folder I have the js & css & images folders plus the *.html and *.jsp files under WEB-INF is where the web.xml folder is. Is there someplace else I should put the html files and how would I map it in the 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-03T05:34:31+00:00Added an answer on June 3, 2026 at 5:34 am

    In order to secure your HTML files, you’ll first need to place them in a secure location. The WEB-INF folder is the only folder deployed in your application that is not accessible by HTTP; thus, a folder there is a good place to keep your HTML files. I recommend /WEB-INF/html.

    Next, you’ll need to tell Spring to map all requests for *.html to the /WEB-INF/html folder. This needs to be placed inside a xml element in your Spring servlet.xml file.

    html-servlet.xml:

    <mvc:resources mapping="/**" location="/WEB-INF/html/" />
    

    See How To Secure MVC Resources for more information.

    You’ll need to add some http entries in your security.xml file for each HTML file:

    <intercept-url pattern="/users-only.html" access="ROLE_USER" />
    

    This uses the Spring filter to check the resource and redirect it based on the user’s role.

    Lastly, you’ll need an entry in web.xml for a servlet that handles requests to *.html:

    web.xml:

    <!--  Security -->
    <servlet>
        <servlet-name>html</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/html-servlet.xml</param-value>
        </init-param>
    </servlet>
    
    <!--  Secure static HTML files. See applicationContext-Security.xml intercept-url for individual HTML file control over security.-->
    <servlet-mapping>
        <servlet-name>html</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently our project is not having any SSL Security. All of the URLs in
I'm currently trying to set up a secured folder with a few pages within
Currently I am using HTML files for parts of my user interface. I display
How can I secure my CakePHP 1.3 site against XSS. Currently I am using
Currently anybody can access the solr admin page by going to my_ip:8983/solr I can't
I'm currently creating an admin platform with a lot of website, these sites can
Here is how our Tomcat webserver is currently setup. We are using jsp for
Currently, I have a website that people can open up during a certain team's
I am having two domains.One is secured and the other is not.Currently,when the user
I have jsp/struts application need to upgrade. Currently we only have 1 websystem(branch) and

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.