• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about web.xml

 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,

Could anybody let me provide complete structure of web.xml. I heard of that it is very useful for exam.
 
Vipul Tulsulkar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Do you have pdf document of servlet spec.2.4?
If yes,then there is a chapter in it called deployment descriptor,which will
give you complete structure of web.xml.
If no,then download it from SCWCDLinks or from java community process.

Regards,
Vipul
SCJP 1.4
SCWCD 1.4
 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some gentlemen had posted this a while ago...I had saved it. Now its your turn... ;-)


################# web.xml.......

<web-app>

<display>A Sample Application</display>

<!-- If the element below appears the application is distributable -->

<distributable/>

<!-- WELCOME FILES -->

<!-- if a url includes folder name, and one of the welcome file is in that folder, it picks that, first match wins -->

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<!-- FILTER CONFIGURATION -->

<filter>
<filter-name>MyFilter</filter-name>
<filter-class>com.example.HelloFilter</filter-class>

<!-- optional and multiple -->
<init-param>
<param-name>FilterName</param-name>
<param-value>Hello Filter</param-value>
</init-param>
<init-param>
<param-name>LogFileName</param-name>
<param-value>UserLog.txt</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>MyFilter</filter-name>


<!-- all the mapping urls mapped first them the servlets -->
<url-pattern>*.do</url-pattern>
<!-- or -->
<servlet-name>MyServlet</servlet-name>



<!-- optional and multiple -->

<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ERROR</dispatcher>


</filter-mapping>

<!-- LISTENER CONFIGURATION/where the attribute itself need to be notified does not require configuration -->
<listener>
<listener-class>com.example.MyContextListener</listener-class>
</listener>



<!-- SERVLET CONFIGURATION -->

<servlet>
<servlet-name>MyServlet</servlet-name>

<servlet-class>com.example.HelloServlet</servlet-class>
<!-- or -->
<jsp-file>/hello.jsp</jsp-file>

<!-- optional and one only, greater value than 0 means don't wait for the first request load it beforehand -->
<load-on-startup>1</load-on-startup>


<!-- optional and multiple -->
<init-param>
<param-name>emailid</param-name>
<param-value>abc@def.com</param-value>
</init-param>

<!-- optional and multiple -->
<security-role-ref>
<role-name>Manager-TOM HENRY</role-name>
<role-link>admin</role-link>
</security-role-ref>
</servlet>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<!-- JSP CONFIGURATION -->
<jsp-config>
<jsp-property-group>
<url-pattern>*.do</url-pattern>
<scipting-invalid>true</scipting-invalid>
<el-ignored>false</el-ignored>
</jsp-property-group>
<taglib>
<taglib-uri>helloWorld</taglib-uri>
<taglib-location>/WEB-INF/hello.tld</taglib-location>
</taglib>
</jsp-config>


<!-- SESSION CONFIGURATION -->
<session-config>
<session-timeout>15</session-timeout>
</session-config>

<!-- ERROR PAGE CONFIGURATION -->
<error-page>

<exception-type>java.lang.ArithimeticException</exception-type>
<!-- or -->
<error-code>500</error-code>

<location>/WEB-INF/error.jsp</location>
</error-page>

<!-- CONTENT TYPE CONFIGURATION -->
<mime-mapping>
<extension>text</extension>
<mime-type>text/html</mime-type>
</mime-mapping>


<!-- ALL SECURITY RELATED CONFIGURATIONS -->
<security-role>
<role-name>admin</role-name>
<role-name>manager</role-name>
</security-role>



<security-constraint>
<web-resource-collection>
<web-resource-name>My Security</web-resource-name>
<!-- one or many -->
<url-pattern>/hello/*.do</url-pattern>

<!-- optional and multiple/ if below tag is not specified all the methods are constrained -->
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>

<auth-constraint>
<!-- optional and multiple/none means all empty means none -->
<role-name>admin</role-name>
<role-name>manager</role-name>
</auth-constraint>

<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
<!-- or
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
<transport-guarantee>INTEGRAL</transport-guarantee>
-->
</user-data-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<!-- one or many -->
<!-- or
<auth-method>DIGEST</auth-method>
<auth-method>CLIENT-CERT</auth-method>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
-->
</login-config>

<!-- ALL EJD/JNDI RELATED CONFIGURATIONS -->
<env-entry>
<env-entry-name></env-entry-name>
<env-entry-type></env-entry-type>
<env-entry-value></env-entry-value>
</env-entry>

<ejb-local-ref>
<ejb-ref-name>ejb/Customer</ejb-ref-name>
<ejb-ref-type>ENTITY</ejb-ref-type>
<local-home>com.example.CustHome</local-home>
<local>come.exampleCust</local>
</ejb-local-ref>

<ejb-ref>
<ejb-ref-name>ejb/Customer</ejb-ref-name>
<ejb-ref-type>ENTITY</ejb-ref-type>
<home>com.example.CustHome</home>
<remote>com.example.Cust</remote>
</ejb-ref>

<resource-env-ref>
<resource-env-ref-name>jms/stockQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>

<resource-ref>
<res-ref-name>jdbc/EmpDB</res-ref-name>
<res-type>javax.sql.Datasource</res-type>
<res-auth>CONTAINER</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

</web-app>



################# and taglib.tld


<taglib>

<tlib-version>1.2</tlib-version>
<short-name>Hello</short-name>
<uri>hello</uri>

<!-- CALLING STATIC METHODS FROM EL(EL FUNCTION CONFIGURATION -->

<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>int rollDice(java.lang.String)</function-signature>
</function>

<!-- CUSTOM TAGS(SIMPLE/CLASSIC) CONFIGURATION -->

<tag>
<description>For Classic/Simple Tags</description>
<name>custom</name>
<tag-class>com.example.TagHandler</tag-class>

<body-content>empty</body-content>
<!-- any of the below -->
<body-content>scriptless</body-content>
<body-content>tagdependent</body-content>
<body-content>JSP</body-content> (only for classic tags)

<attribute>
<name>age></name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

<variable>
<name-from-attribute>id</name-from-attribute>
<variable-class>example.person.Contact</variable-class>

<declare>true</declare>
<!-- optional and one -->
<declare>false</declare>
<declare>yes</declare>
<declare>no</declare>

<scope>AT_BEGIN</scope>
<!-- optional and one -->
<scope>AT_END</scope>
<scope>NESTED</scope>
</variable>

<dynamic-attributes>true</dynamic-attributes>
</tag>

<!-- LET KNOW THE CONTAINER WHERE THE TAG FILES ARE KEPT(ONLY IN CASE OF JAR) -->

<tag-file>
<name>custom</name>
<path>/META-INF/tags/custom.tag</path>
</tag-file>
</taglib>
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original is here http://www.coderanch.com/t/423314/java-Web-Component-SCWCD/certification/Sample-web-xml-may-useful
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understanding web.xml (the deployment descriptor) is about 25% of the topic to study for the exam by my estimate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic