x

Java Deployment Descriptor Questions

PREV     NEXT

Java Deployment Descriptor Questions:


  1. Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at doc-root. Select the one correct answer

A. doc-rootdd.xml
B. doc-rootweb.xml
C. doc-rootWEB-INFweb.xml
D. doc-rootWEB_INFdd.xml
E. doc-rootWEB-INFdd.xml
F. doc-rootWEB_INFweb.xml
G. doc-rootWEB-INFlibdd.xml
H.doc-rootWEB-INFclassesdd.xml

2. Which element of the servlet element in the deployment descriptor is used to specify the parameters for the ServletConfig object. Select the one correct answer.

  1. servlet-config
  2. init-param
  3. load-on-startup
  4. filter

3. Which of these is true about deployment descriptors. Select the one correct answer.

  1. The order of elements in deployment descriptor is not important. The elements can follow any order.
  2. The elements of deployment descriptor are case insensitive.
  3. The servlet-mapping element, if defined, must be included within the servlet element.
  4. The web-app element must include the servlet element.

4. The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Select the one correct answer.

  1. error-page
  2. servlet
  3. exception
  4. error-handling

5. Which of these is a correct fragment within the web-app element of deployment descriptor. Select the one correct answer.

A. <exception> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </exception>

B. <error-page> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </error-page>

C. <error-page> <exception> mypackage.MyException </exception-type> <location> /error.jsp </location> </error-page>

D. <error-page> <exception-type> mypackage.MyException</exception-type> </error-page>

F. <error-page> <servlet-name> myservlet</servlet-name> <exception-type> mypackage.MyException</exception-type> </error-page>

G. <exception> <servlet-name> myservlet</servlet-name> <exception-type> mypackage.MyException</exception-type> </exception>

6. Which element of the deployment descriptor of a web application includes the welcome-file-list element as a subelement. Select the one correct answer.

  1. web-app
  2. welcome-file
  3. servlet
  4. file-list

7. Which of these is a correct fragment within the web-app element of deployment descriptor. Select the two correct answer.

  1. <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page>
  2. <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> <location>/error.jsp</location> </error-page>
  3. <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> </error-page>
  4. <error-page> <exception-type>mypackage.MyException</exception-type> <location>/error.jsp</location> </error-page>

8. Which of these is a correct example of specifying a listener element resented by MyClass class. Assume myServlet element is defined correctly. Select the one correct answer.


A. <listener>MyClass</listener>

B. <listener> <listener-class>MyClass</listener-class></listener>

C. <listener> <listener-name>aListener</listener-name> <listener-class>MyClass</listener-class> </listener>

D. <listener> <servlet-name>myServlet</servlet-name> <listener-class>MyClass</listener-class> </listener>

9. The root of the deployment descriptor is named as

  1. web
  2. web-app
  3. name
  4. display-name

10. With in a context-param element of deployment descriptor, which of the following element is required?

  1. param-name
  2. name
  3. init-param
  4. servlet-name

11. Which of these is not a valid top level element in web-app

  1. icon
  2. listener
  3. eror-page
  4. security-constraint
  5. param-name

12. Which of the follwing are mandatory elements within the filter element. Select two correct answers.

  1. filter-name
  2. name
  3. value
  4. filter-class
  5. init-param

13. Which of these is not a valid value for dispatcher element of filter-mapping. Select the one correct answer.

  1. FORWARD
  2. RESPONSE
  3. INCLUDE
  4. ERROR

14. Which of these is not correct about the filter-mapping element of web-app. Select the one correct answer.

  1. filter-name element must be present in the filter-mapping element.
  2. Either url-pattern or servlet-name must be present in the filter-mapping element.
  3. dispatcher element can be declared zero to three times in the filter-mapping element.
  4. filter-name element in the filter-mapping should be same as the corresponding filter-name element in the filter element of deployment descriptor.

Answers to questions on Deployment Descriptor

      1. C. The deployment descriptor must be called web.xml and be placed in the directory named WEB-INF
      2. B. init-param is used to specify parameters that are accessed using ServletConfig object.
      3. A. In the deployment descriptor the elements in the web-app element can come in any order. B is incorrect because elements are case-sensitive. The servlet-mapping element should be included within the <web-app> element. So C is incorrect. All the elements within the web-app element are optional. So D is incorrect.
      4. a. error-page element in the element web-app element is used to specify the exception name.
      5. b. The error-page element includes exception-type and location as sub-element. Both these elements must be defined.
      6. A. welcome-file-list is included within the web-app element.
      7. A,D. error-page element must include either exception-type or error-code element but not both. It must also include the location element.
      8. B. The element listener-class must be included within the listener element.
      9. B. <web-app> element is the root of the deployment descriptor. It has one attribute named version.
      10. A. param-name and param-value are required within the context-param element.
      11. E. param-name is a child of context-param element.
      12. A and D. filter-name and filter-class are required elements of the filter element.
      13. B. The four possible values of the dispatcher element are – FORWARD, INCLUDE, REQUEST and ERROR. RESPONSE is not a value for the dispatcher element.
      14. C. dispatcher element can be declared upto four times.

PREV     NEXT



Like it? Please Spread the word!

Post Your Thoughts