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




[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. 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?

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

3. Briefly explain the four scopes of a bean in a JSP file. Which scope is the default?

4. What's the difference between the following two lines of code:
5. How do you access the value of a request parameter user in a JSP using EL?

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

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

[Programming] (5pt) Please upload your files using the online turnin server. 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 CS server. Note that file uploading will be disabled automatically after 3PM, so please turn in your work on time.

Problem Description. 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 answers from a user. Once the user completes all the questions, the appliction compares the user solution to the stanrdard solution, and displays a score.

Implementation Details.

1. A sample file for a test can be downloaded here. The format of the file is as follows:
2. Implement a TestEntry class which consists of at least the following methods:
3. Implement a bean TestBean which consistes of at least the following:
4. The JSP page should create a session scope bean of TestBean, 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:

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:
[Discussion]