|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
首先java功能强大的背后是其复杂性,就拿web来说,当今流行的框架有很多,什么struts,spring,jQuery等等,而这无疑增加了java的复杂性。js|在线
一个在线测验体系,测试你的jsp常识,代码不是出格多,以是不加正文了(http://jspbbs.yeah.net)
answer.jsp
<%--Includedirective--%>
<%@includefile="header.html"%>
<TABLEBORDER="0"CELLPADDING="0"CELLSPACING="0">
<TR>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<DIVALIGN="RIGHT">
<FONTSIZE="-1"><AHREF="/developer/Quizzes/index.html">Quizzes
Index</A></FONT></DIV>
<H2ALIGN="RIGHT"><FONTCOLOR="#FFFFFFF">JSPProfessional,Chapter12Quiz
Answers</FONT></H2>
<H4ALIGN="RIGHT"><EM>byDanMalks</EM></H4>
<BR><BR>
<TABLEBORDER="0"CELLSPACING="8"CELLPADDING="2"<TR><TD>
<FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<%--Pagedirectivethatappliestoentirepage.--%>
<%@pagelanguage="java"%>
<%--Identifiesbeanas"worker"andtellsthepagewheretolocatethebean.--%>
<jsp:useBeanid="worker"class="jdc.quiz.QuizResponses"scope="request"/>
<%--Setbeanpropertieswithawildcard.--%>
<jsp:setPropertyname="worker"property="*"/>
<%--Scoring--%>
<%--Variabledeclarationincodescriptlet-->
<%intscore=0;%>
<!--QuizQuestions-->
<!--Question1-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">1.</FONT></TD>
<%--ThemethodgetOne()wassetupinthebeanwiththeid"worker"--%>
<%--AllJavacodeisenclosedin<%%>,leavingHTMLtobeeasily--%>
<%--changedorupdated.--%>
<%if((worker.getOne()!=null)&&((worker.getOne()).equals("D"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif"><B>D</B>
iscorrect!</FONT></TD>
<%}elseif(worker.getOne()!=null){%>
<TDVALIGN="TOP"><FONTCOLOR=red><jsp:getPropertyname="worker"property="one"/>
isincorrect!</FONT></TD>
<%}else{%>
<TDVALIGN="TOP">Blank<FONTCOLOR=red>X</FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
EveryJavaServerPages<SUP><FONTSIZE="-2">TM</FONT></SUP>
(JSP)<SUP><FONTSIZE="-2">TM</FONT></SUP>sourcepageiscompiledinto
aservletbeforeitisexecutedatruntime.</A><BR><BR></FONT></TD></TR>
<!--Question2-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">2.</FONT></TD>
<%if((worker.getTwo()!=null)&&((worker.getTwo()).equals("B"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif"><B>B</B>
iscorrect!<BR></FONT></TD>
<%}elseif(worker.getTwo()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="two"/>is
incorrect</FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank
<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
WhenlargeamountsofJavascriptletcodearemixedwithHTMLmarkup
withinaJSPpage,notonlydoreadabilityandreusesuffer,butoften
bugsareintroducedasweb-productionteammembers,whomaynotbe
familiarwithJavaprogramming,needtomodifytheaccompanyingmarkup.
Additionally,dependenciesnowexistamongvariousteamscompetingforthe
samefile,makingthedevelopmentprocesslessefficient.
</FONT>
</TD></TR>
<!--Question3-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">3.</FONT></TD>
<%if((worker.getThree()!=null)&&((worker.getThree()).equals("D"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif"><B>D</B>
iscorrect!<BR></FONT></TD>
<%}elseif(worker.getThree()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="three"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
DoinganHTTPredirectrequiresaround-triptotheclient.Ifthis
isnotrequired,andtheonlydesireistoforwardtherequestto
anotherresource,thenthiscanbemuchmoreefficientlyaccomplished
withthe<CODE>RequestDispatcher</CODE>.Additionally,whenusingthe
dispatcherthestateoftherequestobjectismaintainedbetween
resources,whichwillnotbethecasewiththeHTTPredirect.
</FONT></TD></TR>
<!--Question4-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">4.</TD>
<%if((worker.getFour()!=null)&&((worker.getFour()).equals("C"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif"><B>C</B>
iscorrect!<BR></FONT></TD>
<%}elseif(worker.getFour()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="four"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Businesslogicisbettercontainedina
JavaBean<SUP><FONTSIZE="-2">TM</FONT></SUP>oraservlet,whichis
ownedbyasoftwaredeveloper.WhenlotsofJavacodeisembedded
directlywithintheJSPpageasscriptlets,the
"cut-and-paste"mentalitytendstoprevailwhenitcomes
tocodereuse.
</FONT>
</TD></TR>
<!--Question5-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">5.</FONT></TD>
<%if((worker.getFive()!=null)&&((worker.getFive()).equals("A"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<B>A</B>iscorrect!<BR></FONT></TD>
<%}elseif(worker.getFive()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="five"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Sincetheservletistheinitialcontactpointforeachrequest,itis
well-suitedtohandlelogicthatiscommonacrossmultiplerequests.
Agoodexampleofthistypeoflogicisanauthenticationcheck.
</FONT>
</TD></TR>
<!--Question6-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">6.</FONT></TD>
<%if((worker.getSix()!=null)&&((worker.getSix()).equals("B"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<B>B</B>iscorrect!<BR></FONT></TD>
<%}elseif(worker.getSix()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="six"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Usingabusinessdelegatereducescouplingbetweenthepresentation
andbusinesstiers.Thepresentationtierhasnoknowledgeofthe
EJBimplementationdetails,suchasJavaNamingandDirectory
Interface<SUP><FONTSIZE="-2">TM</FONT></SUP>lookup.
</FONT>
</TD></TR>
<!--Question7-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">7.</FONT></TD>
<%if((worker.getSeven()!=null)&&((worker.getSeven()).equals("B"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<B>B</B>iscorrect!<BR></FONT></TD>
<%}elseif(worker.getSeven()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="seven"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Blank<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
UsingJavascriptletsistheacceptedmethodofdoingiterationin
JSP<SUP><FONTSIZE="-2">TM</FONT></SUP>1.0.In
JSP<SUP><FONTSIZE="-2">TM</FONT></SUP>1.1,acustomtagmaybeused,
whichwillhidetheimplementationdetailsoftheiterationcode.
</FONT></TD></TR>
<!--Question8-->
<TR><TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">8.
</FONT></TD>
<%if((worker.getEight()!=null)&&((worker.getEight()).equals("A"))){score++;%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<B>A</B>iscorrect!<BR></FONT></TD>
<%}elseif(worker.getEight()!=null){%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
<FONTCOLOR=red><jsp:getPropertyname="worker"property="eight"/>is
incorrect</FONT></FONT></TD>
<%}else{%>
<TD><FONTFACE="Verdana,Arial,Helvetica,sans-serif">Blank
<FONTCOLOR=red>X</FONT></FONT></TD>
<%}%>
<TDVALIGN="TOP"><FONTFACE="Verdana,Arial,Helvetica,sans-serif">
Theterm<I>Page-Centric</I>isusedtodescribeanarchitecturewhere
theinitialcontactpointfortherequestisaJSPpage.Anexample
isshownvisuallybelow:
<P>
</TABLE>
<P>
<%@includefile="footer.html"%>
市场分额,java比asp高一点,因为C#是仿照java开发的,所以哦C#能做的java都能做到,但是java能做的,C#不一定都能做到。毕竟是抄袭吗。 |
|