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