Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 1/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 1
Not yet answered
Marked out of 1.00

When you user Filter is Controller and File properties to mapping:


In label.properties file
second=second.html

This file will be read and loaded to ROADMAP attribute (Map<String, String> type) of context scope
In FilterDispatcher.java file
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
  HttpServletRequest req = (HttpServletRequest)request;  

  String uri = request.getRequestURI();


  int lastIndex = uri.lastIndexOf("/");
  String label = uri.substring(lastIndex + 1);
  ServletContext context = req.getServletContext();

  Map<String, String> roadMap = (Map<String, String>)context.getAttribute("ROADMAP");

  String url = roadMap.get(label);


  RequestDispatcher rd = req.getRequestDispatcher(url);
  rd.forward(request, response);
}
In web.xml file
<filter-mapping>
  <filter-name> FilterDispatcher </filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
In Servlet class, which of following sentence does you use when you want to move second.html?
 

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 2/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Select one:
a. response.sendRedirect(“second”)
b. Both response.sendRedirect(“second”) and request.getRequestDispatcher("second").forward(request, response) can be
used
c. request.getRequestDispatcher("second").forward(request, response)
d. None of the others

Question 2
Not yet answered
Marked out of 1.00

Given the following code snippet


<%
request.setAttribute("a", 4);
request.setAttribute("b", 1);
request.setAttribute("c", 3);
request.setAttribute("d", 6);
%>
What is the output of the expression ${a+b+${c+d}}?

Select one:
a. 59
b. Compile error
c. None of the others
d. 4136
e. 14

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 3/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 3
Answer saved
Marked out of 1.00

Which object does contain not just an SQL statement, but an SQL statement that has been precompiled?

a. Statement
b. PreparedStatement
c. None of the others.
d. ResultSet
e. ResultSetMetaData
f. Connection

Clear my choice

Question 4
Answer saved
Marked out of 1.00

What component is initialized or declared in web deployment descriptor?

Select one or more:


a. Context Path.
b. Context initialization parameter.
c. Session Time out
d. Config parameter.

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 4/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 5
Not yet answered
Marked out of 1.00

Which of these are legal attributes of page directive?


Select all correct answers.

Select one or more:


a. session
b. include
c. isErrorPage
d. import
e. taglib

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 5/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 6
Not yet answered
Marked out of 1.00

What is the output of following code?


<c:out value=“<h2><c:out> example</h2>” escapeXml=“false”/>
Assume that all imports are correct.

Select one:
a. The normal output: “<c:out> example”
b. The error with message: “Attribute escapeXml invalid for tag out according to TLD”
c. Nothing is shown (empty page).
d. The output in h2 tag: “<c:out> example”
e. The error with status code 500.

Question 7
Not yet answered
Marked out of 1.00

Which object do Statement objects return SQL query results?

a. RowSet
b. RecordSet
c. ResultSet
d. DataSet

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 6/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 8
Answer saved
Marked out of 1.00

Suppose we have the code in jsp below


<body>
 <%!
    public void sendMessage(String message) {
      if (message.isEmpty()) {
        message = "World";
     }
      System.out.println("Hello world");
     }
   %>
    <!--This is HTML/XML comment: <%= sendMessage("Phuong") %>-->
</body>
Which HTTP status is shown in client’s browser?
Assume that the url address is correct and allows everyone to access the page

Select one:
a. 200
b. 500
c. 404
d. 403

Clear my choice

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 7/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

Question 9
Not yet answered
Marked out of 1.00

Which way to access parameter named “txtFullname” by using the expression language?

Select one:
a. ${“param.txtFullname”}
b. ${param.txtFullname}
c. ${request.getParameter(“txtFullname”)}
d. ${txtFullname}

Question 10
Not yet answered
Marked out of 1.00

What is the tag of the tag error page (<error-page>) in the web deployment descriptor?

Select one or more:


a. <url-pattern>
b. <exception-type>
c. <error-code>
d. <location>

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 8/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 9/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 10/11
12:53, 05/11/2021 Retake Practical Quiz (page 1 of 4)

https://lms-hcmuni.fpt.edu.vn/mod/quiz/attempt.php?attempt=93132&cmid=5079 11/11

You might also like