Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help in Adding two security constraint in web.xml

 
Hemant Kumar Kawadlar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need help in adding multiple security constraints in web.xml.
I want to add two security constraints in web.xml. I did but while deployment it is giving error in web.xml.
I have added in following manner, sample from web.xml :

<web-app>
<servlet>
</servlet>

<security-constraint>
<display-name>abcConstraint</display-name>

<web-resource-collection>
<web-resource-name>abcCollection</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>TRACE</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
<http-method>OPTIONS</http-method>
</web-resource-collection>

<auth-constraint>
<role-name>abc</role-name>
</auth-constraint>

</security-constraint>


<security-constraint>
<display-name>Access To App</display-name>

<web-resource-collection>
<web-resource-name>App Resource</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>POST</http-method>
</web-resource-collection>

<auth-constraint>
<role-name>def</role-name>
</auth-constraint>

</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>My App</realm-name>
</login-config>

<security-role>
<role-name>abc</role-name>
</security-role>
</security-role>
<role-name>def</role-name>
<security-role>

</web-app>
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
The web.xml XML schema will tell you how to formulate a valid web.xml deployment descriptor.
A copy can be found here: http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
To try your web.xml deployment descriptor out, you can validate it against the schema prior to deployment.
Best wishes!
 
Hemant Kumar Kawadlar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Ivan : Thanks Ivan.. I will check the reference given and validate may web.xml.

@Bear : Surely, I will keep that in mind from next time onwards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic