Jsp online examination system-bean file _ MySQL

Source: Internet
Author: User
Tags http redirect
Examples % TABLEBORDER0CELLPADDING0CELLSPACING0TRTDVALIGNTOPFONTFACEVerd an online examination system to test your jsp knowledge, the code is not so much, so don't add comments (http://jspbbs.yeah.net)
QuizResponses. java

Answer. jsp

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





Quizzes
Index
JSP Professional, Chapter 12 Quiz
Answers
By Dan Malks
































































































































































































































<% -- 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 ++; %> <%} Else if (worker. getOne ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getTwo ()! = Null) & (worker. getTwo (). equals ("B") {score ++; %> <%} Else if (worker. getTwo ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getThree ()! = Null) & (worker. getThree (). equals ("D") {score ++; %> <%} Else if (worker. getThree ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getFour ()! = Null) & (worker. getFour (). equals ("C") {score ++; %> <%} Else if (worker. getFour ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getFive ()! = Null) & (worker. getFive (). equals ("A") {score ++; %> <%} Else if (worker. getFive ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getSix ()! = Null) & (worker. getSix (). equals ("B") {score ++; %> <%} Else if (worker. getSix ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getSeven ()! = Null) & (worker. getSeven (). equals ("B") {score ++; %> <%} Else if (worker. getSeven ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getEight ()! = Null) & (worker. getEight (). equals ("A") {score ++; %> <%} Else if (worker. getEight ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getNine ()! = Null) & (worker. getNine (). equals ("A") {score ++; %> <%} Else if (worker. getNine ()! = Null) {%> <%} Else {%> <% }%> <% If (worker. getTen ()! = Null) & (worker. getTen (). equals ("D") {score ++; %> <%} Else if (worker. getTen ()! = Null) {%> <%} Else {%> <% }%> <% -- Scoring calculations -- %><%Int missed = 10-score;Double grade = (double) score/10*100;%>



<% -- 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. D
Is correct!

Is incorrect!
Blank X
Every JavaServer PagesTM
(JSP) TMsource page is compiled
A servlet before it is executed at runtime.

2. B
Is correct!

Is
Incorrect

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
Same file, making the development process less efficient.

3. D
Is correct!

Is
Incorrect

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
Another resource, then this can be much more efficiently accomplished
WithRequestDispatcher. Additionally, when using
Dispatcher the state of the request object is maintained
Resources, which will not be the case with the HTTP redirect.

4. C
Is correct!

Is
Incorrect

Blank X

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

5.
AIs correct!

Is
Incorrect

Blank X

Since the servlet is the initial contact point for each request, it is
Well-suited to handle logic that is common example SS multiple requests.
A good example of this type of logic is an authentication check.

6.
BIs correct!

Is
Incorrect

Blank X

Using a business delegate reduces coupling between the presentation
And business tiers. The presentation tier has no knowledge of
EJB implementation details, such as Java Naming and Directory
Interfacfe-lookup.

7.
BIs correct!

Is
Incorrect

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.

AIs correct!

Is
Incorrect
Blank
X

The termPage-CentricIs used to describe an architecture where
The initial contact point for the request is a JSP page. An example
Is shown abstrally below:




9.

AIs correct!

Is
Incorrect

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.
DIs correct!

Is
Incorrect

Blank X

Error pages are invoked when there is an uncaught exception from
Within a participating page. In this case, we mention that
validationGaurd()Method might throw an exception.
If this exception is not caught within the page, then we vector
Control toerrorPage, As stipulated in the attribute
Of the given page directive.



You missed<% = Missed %>

Your score is<% = (Int) grade %>Percent.
Source Code

This quiz usedPage-View with Bean Approach, Detailed in HREF = "/developer/Books/triggerverpages/"> Chapter 12, JSP Archeticure. The first
Page of the quiz consists of regular HTML with a form that cils href = "answer.txt">answer.jsp.Answer.jspRequests parameters from the bean,
In this case, called QuizResponses.Page-view with bean
Approach for this quiz required extra work to write the bean, and it cowould have been done using
Page-view approachWithout a bean, requesting invocation directly fromanswer.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 forPage-view with beanApproach
Authentication purposes.

Back to Quiz







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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.