📄 0173.htm
字号:
<html>
<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>jsp在线考试系统-bean文件</strong></big></p>
<div align="right">---摘自互联网</div>
<br>一个在线考试系统,测试你的jsp知识,代码不是特别多,所以不加注释了(http://jspbbs.yeah.net)<br>
QuizResponses.java<br>
<br>
answer.jsp<br>
<br>
<%-- Include directive --%><br>
<%@ include file="header.html" %><br>
<br>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><br>
<TR><br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<DIV ALIGN="RIGHT"> <br>
<FONT SIZE="-1"><A HREF="/developer/Quizzes/index.html">Quizzes <br>
Index</A></FONT></DIV><br>
<H2 ALIGN="RIGHT"><FONT COLOR="#FFFFFFF">JSP Professional, Chapter 12 Quiz <br>
Answers</FONT></H2><br>
<H4 ALIGN="RIGHT"><EM>by Dan Malks</EM></H4><br>
<BR><BR><br>
<TABLE BORDER="0" CELLSPACING="8" CELLPADDING="2" <TR><TD><br>
<FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<br>
<%-- Page directive that applies to entire page. --%><br>
<%@ page language="java" %><br>
<br>
<%-- Identifies bean as "worker" and tells the page where to locate the bean. --%><br>
<jsp:useBean id="worker" class="jdc.quiz.QuizResponses" scope="request" /><br>
<br>
<%-- Set bean properties with a wildcard. --%><br>
<jsp:setProperty name="worker" property="*" /><br>
<br>
<br>
<%-- Scoring --%><br>
<br>
<%-- Variable declaration in code scriptlet --><br>
<% int score = 0; %><br>
<br>
<!-- Quiz Questions --><br>
<br>
<!-- Question 1 --><br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">1.</FONT></TD><br>
<br>
<%-- The method getOne() was set up in the bean with the id "worker" --%><br>
<%-- All Java code is enclosed in <% %>, leaving HTML to be easily --%><br>
<%-- changed or updated. --%><br>
<br>
<% if((worker.getOne() != null) && ((worker.getOne()).equals("D"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>D</B> <br>
is correct!</FONT></TD><br>
<br>
<br>
<% } else if (worker.getOne() != null) { %><br>
<br>
<br>
<TD VALIGN="TOP"><FONT COLOR=red><jsp:getProperty name="worker" property="one" /> <br>
is incorrect!</FONT></TD><br>
<br>
<% } else { %><br>
<br>
<TD VALIGN="TOP">Blank <FONT COLOR=red>X</FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
Every JavaServer Pages<SUP><FONT SIZE="-2">TM</FONT></SUP> <br>
(JSP)<SUP><FONT SIZE="-2">TM</FONT></SUP>source page is compiled into <br>
a servlet before it is executed at runtime.</A><BR><BR></FONT></TD></TR><br>
<br>
<!-- Question 2 --> <br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">2.</FONT></TD><br>
<br>
<br>
<% if ((worker.getTwo() != null) && ((worker.getTwo()).equals("B"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>B</B> <br>
is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getTwo() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="two" /> is <br>
incorrect</FONT></TD><br>
<br>
<% } else { %><br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
Blank <br>
<FONT COLOR=red>X</FONT></FONT></TD><br>
<br>
<% } %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <br>
When large amounts of Java scriptlet code are mixed with HTML markup <br>
within a JSP page, not only do readability and reuse suffer, but often <br>
bugs are introduced as web-production team members, who may not be <br>
familiar with Java programming, need to modify the accompanying markup. <br>
Additionally, dependencies now exist among various teams competing for the <br>
same file, making the development process less efficient.<br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 3 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">3.</FONT></TD><br>
<br>
<% if ((worker.getThree() != null) && ((worker.getThree()).equals("D"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>D</B> <br>
is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getThree() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="three" /> 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>
Doing an HTTP redirect requires a round-trip to the client. If this <br>
is not required, and the only desire is to forward the request to <br>
another resource, then this can be much more efficiently accomplished <br>
with the <CODE>RequestDispatcher</CODE>. Additionally, when using the <br>
dispatcher the state of the request object is maintained between <br>
resources, which will not be the case with the HTTP redirect.<br>
<br>
</FONT></TD></TR><br>
<br>
<!-- Question 4 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">4.</TD><br>
<br>
<% if ((worker.getFour() != null) && ((worker.getFour()).equals("C"))) { score ++; %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"> <B>C</B> <br>
is correct!<BR></FONT></TD><br>
<br>
<br>
<% } else if (worker.getFour() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="four" /> 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>
Business logic is better contained in a <br>
JavaBean<SUP><FONT SIZE="-2">TM</FONT></SUP> or a servlet, which is <br>
owned by a software developer. When lots of Java code is embedded <br>
directly within the JSP page as scriptlets, the <br>
"cut-and-paste" mentality tends to prevail when it comes <br>
to code reuse. <br>
</FONT> <br>
</TD></TR><br>
<br>
<!-- Question 5 --><br>
<br>
<br>
<TR><TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif">5.</FONT></TD><br>
<br>
<% if ((worker.getFive() != null) && ((worker.getFive()).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.getFive() != null) { %><br>
<br>
<TD VALIGN="TOP"><FONT FACE="Verdana, Arial, Helvetica, sans-serif"><br>
<FONT COLOR=red><jsp:getProperty name="worker" property="five" /> is <br>
incorrect</FONT></FONT></TD><br>
<br>
<% } else { %><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -