Search code examples
javatomcatservletsweb.xmlsecurity-constraint

Configuring an exception in web.xml security-constraint


I know there are already other posts similar to my doubt, but the problem is that I could not solve the problem. I have a servlet that must be mapped with the name "passport.jsp", because an external application (can not change the call) makes a request through a URL http://myipserver:portserver/nameApplication/passport.jsp?xxx My web.xml in this point is here:

<servlet-mapping>
    <servlet-name>PortalServlet</servlet-name>
    <url-pattern>/passport.jsp</url-pattern>
</servlet-mapping>

The problem is that the mapping of my security-constraint overrides the definition of the servlet passport.jsp, because is mapping "*.jsp".

<security-constraint>
    <display-name>EsconderJSP</display-name>
    <web-resource-collection>
        <web-resource-name>JSP</web-resource-name>
        <description/>
        <url-pattern>*.jsp</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description/>
        <role-name>jsps</role-name>
    </auth-constraint>
</security-constraint>

Does anyone know how to solve this? You can add the servlet "/passport.jsp" as an exception.

Thank you for your attention.


Solution

  • I solve just adding a new tag in my web.xml (other security-constraint)

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>free pages</web-resource-name>
            <url-pattern>/passport.jsp</url-pattern>
        </web-resource-collection>
    </security-constraint>
    

    Ann it's working. Thanks