Lab 1. Beans, EL, and JSTL
CS320, Spring 2005




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

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 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 7:40PM, so please turn in your work on time.

Problem Description. For this problem you are going to implement an simple course planner using JSP. The course planner works as follows:
Implementation Details.

1. Implement a CoursePlanner class which consists of at least the following methods:
2. Create a JSP page which uses a session scope bean of the CoursePlanner class. When the page is requested without any parameter, it displays the list of all courses and let a user to choose which courses he or she has taken. After the user makes the selection and hit the Submit button, the JSP page displays the list of courses the user can take in the summer quarter, as shown below (for simplicity, only a few courses are listed):

When the page is requested without any parameter:
The user selects CS120, CS202, and MATH207:
After the user clicks Submit:
Please select the courses you have taken:
  • CS101
  • CS120
  • CS122
  • CS201
  • CS202
  • MATH207
  • ...
Please select the courses you have taken:
  • CS101
  • CS120
  • CS122
  • CS201
  • CS202
  • MATH207
  • ...
You may take the following courses in the summer quarter:
  • CS101
  • CS122
  • CS203

Note that in the example above, although the student has fulfilled the prerequisite for CS245, they cannot take the course because it is not offered in the summer.

No scripting elements are allowed in the JSP page.

[HINTS]
public class CoursePlanner {

// constructors and methods

// test code
public static void main( String args[] )
{
CoursePlanner cp = new CoursePlanner();
// some tests
}
}
Note that the time of the lab is limited so don't go overboard with the testing.
[Discussion]