PREV NEXT
Java Deployment Descriptor Questions:
- 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.
- servlet-config
- init-param
- load-on-startup
- filter
3. Which of these is true about deployment descriptors. Select the one correct answer.
- The order of elements in deployment descriptor is not important. The elements can follow any order.
- The elements of deployment descriptor are case insensitive.
- The servlet-mapping element, if defined, must be included within the servlet element.
- 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.
- error-page
- servlet
- exception
- 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.
- web-app
- welcome-file
- servlet
- file-list
7. Which of these is a correct fragment within the web-app element of deployment descriptor. Select the two correct answer.
- <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page>
- <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> <location>/error.jsp</location> </error-page>
- <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> </error-page>
- <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
- web
- web-app
- name
- display-name
10. With in a context-param element of deployment descriptor, which of the following element is required?
- param-name
- name
- init-param
- servlet-name
11. Which of these is not a valid top level element in web-app
- icon
- listener
- eror-page
- security-constraint
- param-name
12. Which of the follwing are mandatory elements within the filter element. Select two correct answers.
- filter-name
- name
- value
- filter-class
- init-param
13. Which of these is not a valid value for dispatcher element of filter-mapping. Select the one correct answer.
- FORWARD
- RESPONSE
- INCLUDE
- ERROR
14. Which of these is not correct about the filter-mapping element of web-app. Select the one correct answer.
- filter-name element must be present in the filter-mapping element.
- Either url-pattern or servlet-name must be present in the filter-mapping element.
- dispatcher element can be declared zero to three times in the filter-mapping element.
- 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
-
-
- C. The deployment descriptor must be called web.xml and be placed in the directory named WEB-INF
- B. init-param is used to specify parameters that are accessed using ServletConfig object.
- 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.
- a. error-page element in the element web-app element is used to specify the exception name.
- b. The error-page element includes exception-type and location as sub-element. Both these elements must be defined.
- A. welcome-file-list is included within the web-app element.
- A,D. error-page element must include either exception-type or error-code element but not both. It must also include the location element.
- B. The element listener-class must be included within the listener element.
- B. <web-app> element is the root of the deployment descriptor. It has one attribute named version.
- A. param-name and param-value are required within the context-param element.
- E. param-name is a child of context-param element.
- A and D. filter-name and filter-class are required elements of the filter element.
- B. The four possible values of the dispatcher element are – FORWARD, INCLUDE, REQUEST and ERROR. RESPONSE is not a value for the dispatcher element.
- C. dispatcher element can be declared upto four times.
-
Post Your Thoughts