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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:37:30+00:00 2026-05-15T09:37:30+00:00

I am fixing some old defects and as part of one defect, I need

  • 0

I am fixing some old defects and as part of one defect, I need to make sure that some requests are being only POST to the JSP page instead of a GET request. The application have a form which submits data to another JSP page (I know its wrong and against MVC but too late to fix it), since it is a JSP page, so we can POST the request or else we can GET the request. In case of a malicious user, can read the form and send the request as a GET from the browser like http://host:80/somejsp.jsp?param=value&param=value etc. In that case, it becomes a violation. I need to make sure that such GET requests are not processed. One way to do is to perform the below steps in the jsp page –

if (request.getMethod().equals("GET")) {
   // reroute the user as it is not a valid req
}

Is there any other way to do it?

  • 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-05-15T09:37:30+00:00Added an answer on May 15, 2026 at 9:37 am

    Two solutions:

    1. Add a <security-constraint> with an empty <auth-constraint> on an <url-pattern> of *.jsp and <http-method> of GET which will block GET requests on JSP files to everyone (as suggested by McDowell):

      <security-constraint>
          <display-name>Restrict GET requests on JSP files</display-name>
          <web-resource-collection>
              <web-resource-name>JSP files</web-resource-name>
              <url-pattern>*.jsp</url-pattern>
              <http-method>GET</http-method>
          </web-resource-collection>
          <auth-constraint />
      </security-constraint> 
      
    2. Create a Filter which listens on an <url-pattern> of *.jsp and does basically the following in the doFilter() method.

      if (((HttpServletRequest) request).getMethod().equals("GET")) {
          ((HttpServletResponse) response).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
      } else {
          chain.doFilter(request, response);
      }
      

    No need to copypaste the same over all JSP pages which would only be prone to IllegalStateException: response already committed errors.

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

Sidebar

Related Questions

I'm fixing bugs for some application, and I need help understanding the following lines
I am fixing a defect in some classic ASP using VBScript and I've come
I have some old C# plugin code that was implemented strictly with Reflection. In
I have a htaccess rule that is fixing some of my previous URL change
Any tips on fixing the emacs error old-style backquotes detected? I'm sure the error
I'm going through some older code in one of my apps and fixing up
I was bug-fixing some code and the compiler warned (legitimately) that the function dynscat()
I've been recently fixing my application that apparently reached some GA quota limitations and
I am fixing some printing (plotter) problems in our java code(windows 32). The paper
I am in the process of fixing some bad UTF-8 encoding. I am currently

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.