Lab 1. Beans, EL, and JSTL
CS320, Fall 2006



[Q&A] (5pt) Please write down your answers to the following questions on a piece of paper, and show it to the instructor before you proceed to the Programming section.

1. In which directory should you put your JSP files

2. Suppose a bean belongs to the package cs320.stuxx. In which directory on the CS3 server should you put the .class file of the bean so your JSP pages can use it?

3. A bean is said to have a write-only property foo, a read-only property bar, and a read/write property fooBar. All properties are of String type. What are the headers of the getter and/or setter methods for these properties? Note that the header of a method includes method name, argument(s), and return type.

4. What's the difference between the following two lines of code:

5. How do you access the value of a bean property user in a JSP using EL?

6. How do you access the value of a request parameter user in a JSP using EL? and how do you check whether the parameter value is null or an empty string?

7. What is the URL to the JSTL Tag Reference documentation?

8. Give an example of using  <c:forTokens>.

[Programming] (5pt) Please upload your files to CSNS. The files should include all the source code, documentation, and an HTML file lab1.html, which contains a link to your JSP page on the CS3 server. Note that file uploading will be disabled at 11:59PM, and no submission will be accepted after that. If you complete the lab by 8:40PM, you will receive 2pt extra credit. 

For this problem you are going to implement an online test application using JSP. The application reads a number of multiple-choice questions from a text file, displays the questions one at a time, and collect the answers from a user. Once the user completes all the questions, the application compares the user solution to the standard solution and displays a score.

A sample file for a test can be downloaded here. The format of the file is as follows:

Implement a TestEntry class which consists of at least the following methods:

Implement a bean TestBean which consists of at least the following:

Create a JSP page Test.jsp that uses a session scope TestBean. Test.jsp displays the test entries one at a time, and displays the score when the user completes the test, as shown in the sample displays below. Note that the score is calculated as (the number of correct answers / the total number of questions * 10).

When the page is requested for the first time:
When the page is displaying the last entry:
After the user clicks FINISH:
You may drive off of the paved roadway to pass another vehicle:
(A) If the shoulder is wide enough to accommodate your vehicle
(B) If the vehicle ahead of you is turning left.
(C) Under no circumstances
To avoid last minute moves, you should be looking down the road to where your vehicle will be in about ______________.
(A) 5 to 10 seconds
(B) 10 to 15 seconds
(C) 15 to 20 seconds

Your score is: 80

Hints:

[PostLab Activities]