1

Can a url-pattern in a web.xml file use the query string to determine the match such as:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>myServletTest</web-resource-name>
        <url-pattern>/myServlet?test=one</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>

Or is that invalid or will it just match myServlet ignoring the query string?

2
  • 2
    What are you trying to do like this? Commented Nov 9, 2011 at 9:44
  • use a different security constraint based upon a value in the query string. One servlet loads different configurations dependant upon a parameter but I want to restrict different roles to different configurations but access to the same servlet. I would be interested in opinions of different approaches within the J2EE environment. Commented Nov 9, 2011 at 12:41

1 Answer 1

5

According to section 12.1 of the Java Servlet Specification Version 3.0 Rev a:

The path used for mapping to a servlet is the request URL from the request object minus the context path and the path parameters.

I don't know what the exact result will be, but it won't be the result you're after since the parameters will be stripped before any servlet is chosen to process the request.

What prohibits you from simply using a different path?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.