Which of the following JSP tags can be used to include the output of another JSP
page into the output of the current page at request time? (Select one)
a <jsp:insert>
b <jsp:include>
c <jsp:directive.include>
d <jsp:directive:include>
e <%@ include %>
Answer:
b
Which listener will get notified when a context is created?
A ServletContextListener
B ServletConfigListener
C HttpServletContextListener
D ContextListener
Answer:
A
When a context is created, the ServletContextListener will be notified and the method contextInitialized(ServletContextEvent) will be invoked.
Which method correctly set an attribute to context ? Select two
A getServletContext().setAttribute(name, value);
B getServletConfig().setAttribute(name, value);
C getServletConfig().getServletContext().setAttribute(name, value);
D response.setAttribute(name, value);
Answer:
A and C
Answer C is correct because always ServletConfig holds a reference to ServletContext
Which method is used to know when a request is created ?
A RequestListener
B ServletRequestListener
C ServletRequestAttributeListener
D servletListener
Answer:
B
When a request is created the ServletRequestListener will be notified
Consider the following code:
<html><body>
${(5 + 3 + a > 0) ? 1 : 2}
</body></html>
Select the correct statement from the options below:
a It will print 1 because the statement is valid.
b It will print 2 because the statement is valid.
c It will throw an exception because a is undefined.
d It will throw an exception because the expression’s syntax is invalid.
Answer:
a
Which of the following is a valid use of the <jsp:useBean> action? (Select one)
a <jsp:useBean id="address" class="AddressBean" />
b <jsp:useBean name="address" class="AddressBean"/>
c <jsp:useBean bean="address" class="AddressBean" />
d <jsp:useBean beanName="address" class="AddressBean" />
Answer:
a
Which of the following elements are required for a valid <taglib> element in
web.xml? (Select two)
a uri
b taglib-uri
c tagliburi
d tag-uri
e location
f taglib-location
g tag-location
h tagliblocation
Answers:
b and f
Which of the following is not a valid subelement of the <attribute> element in
a TLD? (Select one)
a <name>
b <class>
c <required>
d <type>
Answer:
b