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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:47:10+00:00 2026-06-09T15:47:10+00:00

I’m using Struts2+Spring+Hibernate in Tomcat. I’m having an issue with users being able to

  • 0

I’m using Struts2+Spring+Hibernate in Tomcat.

I’m having an issue with users being able to type in a .jsp or .action url directly. Everything they need to access is accessible from the homepage so I want to block this access.

I’ve been looking for an answer and I’ve found some stuff, particularly pertaining to .jsp blocking. I’ve added

<security-constraint>
<web-resource-collection>
<web-resource-name>Deny Direct Access</web-resource-name>
<description></description>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Denied</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Denied</role-name>
</security-role>

to my web.xml but that doesn’t seem to do anything. Then I changed

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*</url-pattern>
</filter-mapping> 

to

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
    <url-pattern>*.html</url-pattern>
    <url-pattern>/index.jsp</url-pattern>
</filter-mapping> 

which blocks some .jsp files but not others. I’ve made sure not to put

<url-pattern>*.jsp</url-pattern>

in any of my security roles.

I’ve heard I can put all my jsps in /Web-inf but this seems like a big hassle as I’ll then have to change the paths in every instance of my application where I reference them.

I also can’t find anything involving blocking direct access to .action classes. If there is someone I can be pointed to find this information, it would be much appreciated. Thanks.

  • 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-09T15:47:12+00:00Added an answer on June 9, 2026 at 3:47 pm

    If you place your JSPs under the /WEB-INF directory, then they will not be accessible directly.

    As for .actions, you’re out of luck there — you can’t stop someone from going directly to the URL for a web page (which is what an .action ultimately is).

    Why would you want to stop people from going directly to an URL? Being able to link directly to things is a pretty fundamental part of the web.

    Update

    Since you’re looking for a way to control access, you could create an interface and then create an interceptor. In the interceptor, check if the current action implements the interface, and if so, invoke the method on the interface.

    Here’s an example:

    public interface SecurableAction {
      void checkSecurity();
    }
    
    public class SecurityInterceptor extends AbstractInterceptor {
      @Override
      public String intercept(ActionInvocation invocation) throws Exception {
        Object action = invocation.getAction();
        if (action instanceof SecurableAction) {
            ((SecurableAction) action).checkSecurity();
        }
    
        return invocation.invoke();
      }
    }
    

    Finally, in your action’s checkSecurity() method, check that the current user has access to invoke the action. If the user does not have access, throw an exception of some sort (I usually create one called AccessViolation and then map it to a custom error page).

    public class YourAction implements SecurableAction {
      @Override
      public void checkSecurity() {
        if (!currentUser.hasPermission("MANAGE_OTHER_USERS")) {
          throw new AccessViolation();
        }
      }
    }
    

    Remember to add this new interceptor to your stack.

    As an alternative to all of this, you could use the Preparable interface to provide all of this as well, but I find it nicer to have a separate method to encapsulate security checks.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

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.