📄 0173.htm
字号:
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
Since the servlet is the initial contact point for each request, it is <br>
well-suited to handle logic that is common across multiple requests. <br>
A good example of this type of logic is an authentication check. <br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 6 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">6.</FONT></TD><br>
<br>
<% if ((worker.getSix() != null) && ((worker.getSix()).equals("B"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"> <FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<B>B</B> is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getSix() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="six" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
Using a business delegate reduces coupling between the presentation <br>
and business tiers. The presentation tier has no knowledge of the <br>
EJB implementation details, such as Java Naming and Directory <br>
Interface<SUP><FONT SIZE="-2">TM</FONT></SUP> lookup.<br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 7 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">7.</FONT></TD><br>
<br>
<% if ((worker.getSeven() != null) && ((worker.getSeven()).equals("B"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
<B>B</B> is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getSeven() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="seven" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
Using Java scriptlets is the accepted method of doing iteration in <br>
JSP<SUP><FONT SIZE="-2">TM</FONT></SUP> 1.0. In <br>
JSP<SUP><FONT SIZE="-2">TM</FONT></SUP> 1.1, a custom tag may be used, <br>
which will hide the implementation details of the iteration code.<br>
<br>
</FONT></TD></TR><br>
<br>
<!-- Question 8 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">8.<br>
</FONT></TD><br>
<br>
<% if ((worker.getEight() != null) && ((worker.getEight()).equals("A"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
<B>A</B> is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getEight() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="eight" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
<TD><FONT FACE="Verdana, Arial, Helvetica, sans-serif">Blank <br>
<FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
The term <I>Page-Centric</I> is used to describe an architecture where <br>
the initial contact point for the request is a JSP page. An example <br>
is shown visually below:<br>
<P><br>
<IMG SRC="Image1.gif" WIDTH="412" HEIGHT="204" ALT="JSP Page-Centric"><br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 9 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">9.<br>
</FONT></TD><br>
<br>
<% if ((worker.getNine() != null) && ((worker.getNine()).equals("A"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
<B>A</B> is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getNine() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="nine" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
When the forward method is used, the invoking resource does not regain <br>
control. Multiple include invocations can be made from the same <br>
resource, while the invoking resource maintains execution control.<br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 10 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">10.<br>
</FONT></TD><br>
<br>
<% if ((worker.getTen() != null) && ((worker.getTen()).equals("D"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"> <B>D</B> is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getTen() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="ten" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Error pages are invoked when there is an uncaught exception from <br>
within a particular page. In this case, we mention that the <br>
<CODE>validationGaurd()</CODE> method might throw an exception. <br>
If this exception is not caught within the page, then we vector <br>
control to the <CODE>errorPage</CODE>, as stipulated in the attribute <br>
of the given page directive.<br>
<br>
<br>
</FONT></TD></TR><br>
<%-- Scoring calculations --%><br>
<% <br>
int missed = 10 - score;<br>
double grade = (double)score/10*100;<br>
%><br>
<br>
<TR><TD colspan="3"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
<P>You missed<STRONG> <%= missed %></STRONG><br>
<BR>Your score is<STRONG> <%= (int)grade %> </STRONG> percent.<br>
<H4>Source Code</H4><br>
<P>This quiz used the <I>Page-View with Bean Approach</I>, detailed in <A <br>
HREF="/developer/Books/javaserverpages/">Chapter 12, JSP Archeticure</A>. The <A HREF="index.txt">first <br>
page</A> of the quiz consists of regular HTML with a form that calls <A <br>
HREF="answer.txt"><CODE>answer.jsp</CODE></A>. <CODE>Answer.jsp</CODE> requests parameters from the bean, <br>
in this case, called <A HREF="QuizResponses.txt">QuizResponses</A>. The <I>page-view with bean</I> <br>
approach for this quiz required extra work to write the bean, and it could have been done using the <br>
<I>page-view approach</I> without a bean, requesting invocation directly from the <CODE>answer.jsp</CODE> <br>
page. Deciding which approach is preferrable depends on the application and how much HTML and Java <br>
scriptlets need to be used. For this quiz we opted for the <I>page-view with bean</I> approach for <br>
illustration purposes.<br>
<br>
<P><A HREF=/developer/Quizzes/jsp/index.html>Back to Quiz</A><br>
<P><IMG SRC=/images/T7.gif ALIGN=LEFT><br>
<br>
<br>
</TABLE><br>
<P> <br>
<br>
<%@ include file="footer.html" %>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -