您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
jsp在线考试系统-jsp文件
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:27:39
一个在线考试系统,测试你的jsp知识,代码不是特别多,所以不加注释了(http://jspbbs.yeah.net)

answer.jsp

<%-- Include directive --%>
<%@ include file="header.html" %>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<DIV ALIGN="RIGHT">
<FONT SIZE="-1"><A HREF="/developer/Quizzes/index.html">Quizzes
Index</A></FONT></DIV>
<H2 ALIGN="RIGHT"><FONT COLOR="#FFFFFFF">JSP Professional, Chapter 12 Quiz
Answers</FONT></H2>
<H4 ALIGN="RIGHT"><EM>by Dan Malks</EM></H4>
<BR><BR>
<TABLE BORDER="0" CELLSPACING="8" CELLPADDING="2" <TR><TD>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<%-- Page directive that applies to entire page. --%>
<%@ page language="java" %>

<%-- Identifies bean as "worker" and tells the page where to locate the bean. --%>
<jsp:useBean id="worker" class="jdc.quiz.QuizResponses" scope="request" />

<%-- Set bean properties with a wildcard. --%>
<jsp:setProperty name="worker" property="*" />


<%-- Scoring --%>

<%-- Variable declaration in code scriptlet -->
<% int score = 0; %>

<!-- Quiz Questions -->

<!-- Question 1 -->

<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">1.</FONT></TD>

<%-- The method getOne() was set up in the bean with the id "worker" --%>
<%-- All Java code is enclosed in <% %>, leaving HTML to be easily --%>
<%-- changed or updated. --%>

<% if((worker.getOne() != null) && ((worker.getOne()).equals("D"))) { score ++; %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>D</B>
is correct!</FONT></TD>


<% } else if (worker.getOne() != null) { %>


<TD VALIGN="TOP"><FONT COLOR=red><jsp:getProperty name="worker" property="one" />
is incorrect!</FONT></TD>

<% } else { %>

<TD VALIGN="TOP">Blank <FONT COLOR=red>X</FONT></TD>

<% } %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
Every JavaServer Pages<SUP><FONT SIZE="-2">TM</FONT></SUP>
(JSP)<SUP><FONT SIZE="-2">TM</FONT></SUP>source page is compiled into
a servlet before it is executed at runtime.</A><BR><BR></FONT></TD></TR>

<!-- Question 2 -->


<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">2.</FONT></TD>


<% if ((worker.getTwo() != null) && ((worker.getTwo()).equals("B"))) { score ++; %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>B</B>
is correct!<BR></FONT></TD>


<% } else if (worker.getTwo() != null) { %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<FONT COLOR=red><jsp:getProperty name="worker" property="two" /> is
incorrect</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 large amounts of Java scriptlet code are mixed with HTML markup
within a JSP page, not only do readability and reuse suffer, but often
bugs are introduced as web-production team members, who may not be
familiar with Java programming, need to modify the accompanying markup.
Additionally, dependencies now exist among various teams competing for the
same file, making the development process less efficient.
</FONT>
</TD></TR>

<!-- Question 3 -->


<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">3.</FONT></TD>

<% if ((worker.getThree() != null) && ((worker.getThree()).equals("D"))) { score ++; %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>D</B>
is correct!<BR></FONT></TD>


<% } else if (worker.getThree() != null) { %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<FONT COLOR=red><jsp:getProperty name="worker" property="three" /> 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">
Doing an HTTP redirect requires a round-trip to the client. If this
is not required, and the only desire is to forward the request to
another resource, then this can be much more efficiently accomplished
with the <CODE>RequestDispatcher</CODE>. Additionally, when using the
dispatcher the state of the request object is maintained between
resources, which will not be the case with the HTTP redirect.

</FONT></TD></TR>

<!-- Question 4 -->


<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">4.</TD>

<% if ((worker.getFour() != null) && ((worker.getFour()).equals("C"))) { score ++; %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>C</B>
is correct!<BR></FONT></TD>


<% } else if (worker.getFour() != null) { %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<FONT COLOR=red><jsp:getProperty name="worker" property="four" /> 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">
Business logic is better contained in a
JavaBean<SUP><FONT SIZE="-2">TM</FONT></SUP> or a servlet, which is
owned by a software developer. When lots of Java code is embedded
directly within the JSP page as scriptlets, the
&quot;cut-and-paste&quot; mentality tends to prevail when it comes
to code reuse.
</FONT>
</TD></TR>

<!-- Question 5 -->


<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">5.</FONT></TD>

<% if ((worker.getFive() != null) && ((worker.getFive()).equals("A"))) { score ++; %>

<TD VALIGN="TOP"> <FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<B>A</B> is correct!<BR></FONT></TD>


<% } else if (worker.getFive() != null) { %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<FONT COLOR=red><jsp:getProperty name="worker" property="five" /> 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">
Since the servlet is the initial contact point for each request, it is
well-suited to handle logic that is common across multiple requests.
A good example of this type of logic is an authentication check.
</FONT>
</TD></TR>

<!-- Question 6 -->


<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">6.</FONT></TD>

<% if ((worker.getSix() != null) && ((worker.getSix()).equals("B"))) { score ++; %>

<TD VALIGN="TOP"> <FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<B>B</B> is correct!<BR></FONT></TD>


<% } else if (worker.getSix() != null) { %>

<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<FONT COLOR=red><jsp:getProperty name="worker" prope

[1] [2] 下一页


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |