Lab Assignment 1
CS320, Spring 2004


[Q&A] (5pt) Please write down your answers to the following questions on a piece of paper.

About cs.calstatela.edu

1. What's the full path (or absolute path) of your home directory on the server?

2. If we use $HOME to represent your home directory, in what directory do you put your servlet .class files?

3. Suppose you put a Foo.class under the directory $HOME/public_html/WEB-INF/classes, what url do you use to access this servlet in a browser?

4. If we use $HOME to represent your home directory, in what directory do you put your JSP .jsp files?

5. Suppose you put a Foo.jsp under the directory $HOME/public_html, what url do you use to access this JSP page in a browser?

6. Do you need a web.xml file?
A. Yes, in $HOME/public_html
B. Yes, in $HOME/public_html/WEB-INF
C. Yes, in $HOME/public_html/WEB-INF/classes
D. No, if you received less than 20pt in the midterm. In fact, if you have a web.xml file, you should remove it immediately.
About Java Beans

1. What are the three characteristics of Bean for Dummies?

2. Suppose a bean FooBean has a property called user, what are the method headers for the get and set methods of this property.

3. Why do you need to put a bean in a package, and how do you do that?

4. Suppose you put your beans in the package edu.csula.studentx and complied them. In which directory should you put the .class files of the beans so your JSP files can use them?

5. How do you declare a bean in a JSP file. Give an example.

6. Explain the four scopes of a bean in a JSP file. Which scope is the default?

7. In a JSP file, how do you set the value of a property in a bean? and how do you set the values of all properties in a bean?

8. In a JSP file, how do you read the value of a property in a bean?

9. What's the difference between the following two lines of code:
About Expression Language (EL)

1. How to you access the value of a request parameter user in a JSP using EL?

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

About JSTL

1. What's the url to the JSTL tag documentation?

2. Give an example of using <c:if>.

3. Give an example of using <c:choose>, <c:when>, and <c:otherwise>

[Programming] (5pt) Use a JSP Validate.jsp to validate the user input from User.html. If the length of the user name is less than 4 characters or the course name is not CS320, Validate.jsp should display "invalid user or course"; otherwise display the user name and the course name. You must use a bean in Validate.jsp. The bean should have at least three properties: user, course, and valid. Both files have to be placed on the server and work properly there.