Professional Documents
Culture Documents
Enthuware
Enthuware
html to be added
to the html content that your servlet generates. Which of the following code fragments occuring
in doGet method would achieve this objective?
<html>
<head>
<title> Test Page </title>
<body>
Today's Date is
</body>
</html>
Options:
<%@import package='java.util.*' %> <%@page import='java.util.*' %>
<%=new Date()%> <%new Date()%>
Correct Answer(s)
<%@import package='java.util.*' %>
<html>
<head>
<title> Test Page </title>
<body>
Today's Date is <%=new Date()%>
</body>
</html>
b ${pageContext.contextPath}
getContextPath() is a method in HttpServletRequest and not in pageContext.
c ${requestScope.contextPath}
requestScope is an implicit object but it contains the attributes. It is not same as
ServletRequest object.
d ${pageContext.request.contextPath}
pageContext is an implicit object. It does contain 'request' object of class
HttpServletRequest. getContextPath() can be called on this object.
e ${pageContext.requestScope.contextPath}
pageContext.requestScope does not make sense.
f ${requestScope.request.contextPath}
requestScope does not contain request object.
g ${contextPath}
contextPath is not an implicit object.
Select the correct sequence of actions that a servlet container performs before servicing
any request.
1. Instantiate listeners defined in the deployment descriptor.
2. Initialize filters defined in the deployment descriptor.
3. Initialize servlets that are set to load on startup.
4. Call the contextInitialized method on the listeners implementing
ServletContextListener interface.
Correct Answer(s)
1423
In file companyhome.jsp:
<html><body>
Welcome to ABC Corp!
<%@ page errorPage="simpleerrorhandler.jsp" %>
<%@ include file="companynews.jsp" %>
</body></html>
In file companynews.jsp:
<%@ page errorPage="advancederrorhandler.jsp" %>
<h3>Todays News</h3>
Which of the following statements are correct?
Select 1 correct option.
a When companyhome.jsp is requested, the output will contain "welcome..." as
well as "Todays News".
b companyhome.jsp will not compile.
d Both the files will compile but will throw an exception at runtime.
e None of these.