[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. Suppose your account on the CS3 server is cs320stu31, and you have a servlet Foo.java that belongs to a package bar. On the CS3 server, in which directory should you put Foo.class? Where do you put the web.xml file, and what needs to be added to web.xml so that the servlet can be accessed through the URL http://cs3.calstatelae.edu:8080/cs320stu31/FooServlet?
2. Suppose you have a JSP file Foo.jsp. Foo.jsp uses a bean of the class Bar that belongs to the package cs320.stu31. In which directories on the CS3 server should you put Foo.jsp and Bar.class? And what is the URL to access Foo.jsp?
3. A bean Foobar 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 only the method name, argument(s), and return type, i.e. no method body.
4. Suppose the Foobar bean is declared in a JSP page with <jsp:useBean class="cs320.Foobar" id="fb" />. How do you access the value of the property fooBar in the JSP using EL?
5. What's the difference between the following two lines of code:
6. How do you access the value of a request parameter foobar 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 (if any), 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 10:30PM, and no submission will be accepted after that.
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]