answer.jsp
<%-- Include directive --%>
<%@ include file="header.html" %>
JSP Professional, Chapter 12 Quiz |
<%-- 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) { %> 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) { %> 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) { %> 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) { %> 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) { %> 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) { %> 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) { %> 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: 9. | <% if ((worker.getNine() != null) && ((worker.getNine()).equals("A"))) { score ++; %> | A is correct! <% } else if (worker.getNine() != null) { %> 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) { %> 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 %> Source CodeThis quiz used the Page-View with Bean Approach, detailed in HREF="/developer/Books/javaserverpages/">Chapter 12, JSP Archeticure. The first |
<%@ include file="footer.html" %>
相关文章推荐
• 【活动】充值PHP中文网VIP即送云服务器• sql与mysql有什么区别• mysql分页查询怎么优化• mysql怎么查询临时表• mysql存储过程中的循环语句有哪些• mysql中事务和存储过程是什么独孤九贱(3)_JavaScript视频教程
javascript是运行在浏览器上的脚本语言,连续多年,被评为全球最受欢迎的编程语言。是前端开发必备三大法器中,最具杀伤力。如果前端开发是降龙十八掌,好么javascript就是第18掌:亢龙有悔。没有它,你的前端生涯是不完整的。《php.cn独孤九贱(3)-JavaScript视频教程》课程特色:php中文网原创幽默段子系列课程,以恶搞,段子为主题风格的php视频教程!轻松的教学风格,简短的教学模式,让同学们在不知不觉中,学会了javascript知识。
JavaScript教程127044次播放
独孤九贱(6)_jQuery视频教程
jQuery是一个快速、简洁的JavaScript框架。设计的宗旨是“write Less,Do More”,即倡导写更少的代码,做更多的事情。它封装JavaScript常用的功能代码,提供一种简便的JavaScript设计模式,优化HTML文档操作、事件处理、动画设计和Ajax交互。 核心特性可以总结为:具有独特的链式语法和短小清晰的多功能接口;具有高效灵活的css选择器,并且可对CSS选择器进行扩展;拥有便捷的插件扩展机制和丰富的插件。兼容各种主流浏览器,如IE 6.0+、FF 1.5+、Safari 2.0+、Opera 9.0+等,是全球最流行的前端开发框架之一。PHP中文网根据最新版本,独家录制jQuery最新视频教程,回馈PHP中文网的新老用户。
jQuery教程105080次播放
jQuery与Ajax基础与实战
jQuery是最流行的JS函数库,封装了许多实用的功能,其中最引人入胜的就是Ajax。 jQuery中的Ajax操作,语法简单,操作方便,使Ajax从未如此轻松,前端人员从此不再为与服务器异步交互而发愁,本套课程,精选了最常用的几个方法,从基本的语法到每个参数,再到具体实例进行了全面的讲解。
AJAX教程5944次播放
Git教程(60分钟全程无废话版)
Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。 Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。 Git 与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式,不必服务器端软件支持
JavaScript教程5144次播放