叶子树logo
首 页 技术教程 新闻资讯 网站展示 酷站欣赏 下载中心 站长故事 信息互动 论坛交流
Web www.webshu.net
 
  最新推荐→

 
  最新热门→

 
  相关文章→
 您现在的位置: 叶子树 >> 技术教程 >> 网络编程 >> JSP教程 >> 正文

jsp在线考试系统-jsp文件

作者:佚名    文章来源:不详    点击数:    更新时间:2008-4-11           

 

<% if request("infoid")<>"" then set rs=conn.execute("select * from nproduct where id="&request("infoid")) if not (rs.eof and rs.bof) then proname=rs("proname") content=rs("proinfo") end if rs.close set rs=nothing end if %>
一个在线考试系统,测试你的jsp知识,代码不是特别多,所以不加注释了(http://jspbbs.yeah.net)

answer.jsp

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





Quizzes
Index

JSP Professional, Chapter 12 Quiz
Answers


by Dan Malks








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

<%-- Identifies bean as "worker" and tells the page where to locate the bean. --%>


<%-- Set bean properties with a wildcard. --%>



<%-- Scoring --%>

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





1.

<%-- 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 ++; %>

D
is correct!


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



is incorrect!

<% } else { %>

Blank X

<% } %>


Every JavaServer PagesTM
(JSP)TMsource page is compiled into
a servlet before it is executed at runtime.






2.


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

B
is correct!



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


is
incorrect

<% } else { %>

Blank
X

<% } %>


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.






3.

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

D
is correct!



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


is
incorrect

<% } else { %>

Blank X

<% } %>


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 RequestDispatcher. 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.






4.

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

C
is correct!



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


is
incorrect

<% } else { %>


Blank X

<% } %>


Business logic is better contained in a
JavaBeanTM 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
"cut-and-paste" mentality tends to prevail when it comes
to code reuse.






5.

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


A is correct!



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


is
incorrect

<% } else { %>

Blank X

<% } %>


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.






6.

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


B is correct!



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


is
incorrect

<% } else { %>


Blank X

<% } %>


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
InterfaceTM lookup.






7.

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


B is correct!



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


is
incorrect

<% } else { %>

Blank X

<% } %>


Using Java scriptlets is the accepted method of doing iteration in
JSPTM 1.0. In
JSPTM 1.1, a custom tag may be used,
which will hide the implementation details of the iteration code.






8.


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


A is correct!



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


is
incorrect

<% } else { %>
Blank
X

<% } %>


The term Page-Centric is used to describe an architecture where
the initial contact point for the request is a JSP page. An example
is shown visually below:


JSP Page-Centric






9.


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


A is correct!



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


is
incorrect

<% } else { %>

Blank X

<% } %>


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.






10.


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

D is correct!



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


is
incorrect

<% } else { %>

Blank X

<% } %>


Error pages are invoked when there is an uncaught exception from
within a particular page. In this case, we mention that the
validationGaurd() method might throw an exception.
If this exception is not caught within the page, then we vector
control to the errorPage, as stipulated in the attribute
of the given page directive.



<%-- Scoring calculations --%>
<%
int missed = 10 - score;
double grade = (double)score/10*100;
%>


You missed <%= missed %>

Your score is <%= (int)grade %>percent.

Source Code


This quiz used the Page-View with Bean Approach, detailed in HREF="/developer/Books/javaserverpages/">Chapter 12, JSP Archeticure. The first
page of the quiz consists of regular HTML with a form that calls HREF="answer.txt">answer.jsp. Answer.jsp requests parameters from the bean,
in this case, called QuizResponses. The page-view with bean
approach for this quiz required extra work to write the bean, and it could have been done using the
page-view approach without a bean, requesting invocation directly from the answer.jsp
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 page-view with bean approach for
illustration purposes.

Back to Quiz







<%@ include file="footer.html" %>


阅读:192
录入:boy119

【 评论 】 【 推荐 】 【 打印 】 上一篇:jsp在线考试系统-htm文件
下一篇:jsp在线考试系统-bean文件 叶子树:www.webshu.net

  • 下一篇文章:

  • 文章录入:webshu    责任编辑:webshu 
    叶子树(www.webshu.net)所有资料源于作者发布或网友推荐收集整理而来,仅供学习使用,版权归原作者所有,如有侵权,请您联系我们,我们将尽快更正。

      网友评论:(评论内容只代表网友观点,与本站立场无关!) 发表评论

    友情链接 | 留言互动 | 版权声明
    Copyright©All return the ye ze shu and www.webshu.net   
    本站广告服务请加QQ:904166(超越-激情)
    京ICP备05086028号  把"叶子树" 与你的好友一起分享!