Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 61 pages
Exam (elaborations)

ALL PRJ321 || 100% NO ERROR.

Document preview thumbnail
Preview 4 out of 61 pages

ALL PRJ321 || 100% NO ERROR.

Content preview

ALL PRJ321 || 100% NO ERROR.
E. Web page returned showing a heading and the current date correct answers 1. What will be
the most likely outcome of attempting to access the following JSP for the second
time? (Choose one.)
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html><head><title>Chapter 6 Question 1</title></head>
<body>
<h1>Chapter 6 Question 1</h1>
<%!
public void jspInit() {
System.out.println("First half of jspInit()");
%>
<%> new Date() %>
<%!
System.out.println("Second half of jspInit()");
}
%>
</body></html>
A. Translation error (HTTP response code of 500)
B. Page not found error (HTTP response code of 404)
C. Web page returned showing a heading and the current date; two lines of output written to
the server log
D. Web page returned showing "First half of jspInit()," "Second half of jspInit()," a heading,
and the current date
E. Web page returned showing a heading and the current date

D. 3 correct answers 2. What is output to the web page on the second access to the same
instance of the following JSP?
(Choose one.)
<%@ page language="java" %>
<html>
<head><title>Chapter 6 Question 2</title></head>
<body>
<h1>Chapter 6 Question 2</h1>
<%! int x = 0; %>
<%!
public void jspInit() {
System.out.println(x++);
}
%>
<%= x++ %>
<% System.out.println(x); %>
<% jspInit(); %>
</body></html>
A. 0
B. 1
C. 2
D. 3

,E. 4
F. Page does not translate.
G. Page translates, but there is another runtime error.

A. Expression embedded in declaration. correct answers 3. For what reason does the
following JSP fail to translate and compile? (Choose one.)
<%@ page language="java" %>
<html>
<head><title>Chapter 6 Question 3</title></head>
<body>
<h1>Chapter 6 Question 3</h1>
<%! int x; %>
<%!
public void jspDestroy() {
System.out.println("self-destructing");
} %>
<%!
public void jspInit() {
System.out.println(<%= x %>);
}
%>
</body></html>
A. Expression embedded in declaration.
B. Data member x not initialized before use.
C. Local variable x not initialized before use.
D. Placement of jspDestroy() method before jspInit() method.
E. The page actually compiles and translates without any problem.
F. None of the above.

A. The _jspService() method is called from the generated servlet's service() method.
D. All servlet methods are accessible from the jspInit() method. correct answers 4. Which of
the following are true statements about the JavaServer Page life cycle?
(Choose two.)
A. The _jspService() method is called from the generated servlet's service() method.
B. jspInit() is only ever called on the fi rst request to a JSP instance.
C. jspDestroy() is only ever called on the last request to a JSP instance.
D. All servlet methods are accessible from the jspInit() method.
E. You cannot override or provide a no-parameter init() method in a JSP page.

A. Cannot resolve symbol compilation error.
E. Duplicate method compilation error. correct answers 5. What is the consequence of
attempting to access the following JSP page?
(Choose two.)
<%@ page language="java" %>
<html>
<head><title>Chapter 6 Question 5</title></head>
<body>
<h1>Chapter 6 Question 5</h1>
<%!public void _jspService(HttpServletRequest request,
HttpServletResponse response) {

,out.write("A");
} %>
<% out.write("B"); %>
</body>
</html>
A. Cannot resolve symbol compilation error.
B. "A" is output to the response.
C. "B" is output to the response.
D."A" is output to the response before "B."
E. Duplicate method compilation error.
F. "B" is output to the response before "A."

B. A translation error occurs. correct answers 6. What is the result of attempting to access the
following JSP page? (Choose one.)
<html>
<head><title>Chapter 6 Question 6</title></head>
<body>
<h1>Chapter 6 Question 6</h1>
<%! public String methodA() {
return methodB();
}
%>
<%! public String methodB() {
return methodC();
}
%>
<% public String methodC() {
return "Question 6 Text";
}
%>
<h2><%= methodA() %></h2>
</body>
</html>
A. "Question 6 Text" is output to the resulting web page.
B. A translation error occurs.
C. A runtime error occurs.
D. The text between the <h1></h1> HTML tags appears, followed by a Java stack
trace.
E. The web page is blank.

B. In JSP technology, it's a bad idea to get hold of the PrintWriter directly from the response.
H. The page has a compilation error for other reasons. correct answers 8. What true
statements can you make about the following JSP page source? The line
numbers are for reference only and should not be considered part of the source.
(Choose two.)
01 <%@ page import="java.io.*" %>
02 <html>
03 <head><title>Chapter 6 Question 8</title></head>
04 <body>
05 <%

, 06 PrintWriter out = response.getWriter();
07 out.write("P");
08 %>
09 <% out.write("Q"); %>
10 </body>
11 </html>
A. In line 09, the scriptlet markers should not be on the same line as the Java source
statement.
B. In JSP technology, it's a bad idea to get hold of the PrintWriter directly from the response.
C. "P" will be written to the response, followed by "Q."
D. "Q" will be written to the response, followed by "P."
E. Only "Q" will be written to the response.
F. The page has a compilation error because of a directive syntax error.
G. The page has a compilation error because the import in the directive syntax is for
the wrong Java package.
H. The page has a compilation error for other reasons.

A. It is legal to embed a <%--style comment inside another comment.
C. It is legal to embed an expression inside a declaration.
D. It is legal to embed an expression inside a directive. correct answers 9. Which of the
following are false statements to make about JSP scripting elements?
(Choose three.)
A. It is legal to embed a <%--style comment inside another comment.
B. It is legal to embed an expression inside a scriptlet.
C. It is legal to embed an expression inside a declaration.
D. It is legal to embed an expression inside a directive.
E. It is legal to include a declaration at any point in the JSP page source, provided that
it appears outside of other elements.
F. It is legal to embed a scriptlet inside an expression inside a <%--style comment.

D. The JSP page would compile if one of the percent (%) signs were removed. correct
answers 10. What is the result of attempting to access the following JSP page source?
(Choose one.)
<% <%-- for (int i = 0; i < 10; i++) {
<%-- if(i==3) System.out.println("i is 3!");--%>
System.out.println("i squared is " + i * i);
} %> --%>
A. Doesn't translate because the page source is incomplete.
B. Doesn't compile because nesting comments in this way is illegal.
C. The JSP page would compile if the terminating curly brace were removed.
D. The JSP page would compile if one of the percent (%) signs were removed.
E. Runs as is and produces output (possibly not the output intended).

D. <%@ page import='java.util.*, java.io.PrintStream'
import="java.text.*" %>
E. <%@page import = " java.util.* "%> correct answers 11. Which of the following
constitute valid ways of importing Java classes into JSP page source?
(Choose two.)
A. <%! import java.util.*; %>
B. <%@ import java.util.* %>

Document information

Uploaded on
November 26, 2025
Number of pages
61
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
SirAnton
3.7
(118)
Sold
789
Followers
438
Items
39711
Last sold
12 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions