Lab Assignment 2
CS320, Spring 2004
[Programming] (5pt)
1. Create a table UserInfo in your MySQL database. The UserInfo table should have two fields, user and course. Poplulate the table with some records, one of which should be <"csun", "cs320">.
2. Modify your bean implemented in Lab 1 such that the bean property valid is only true if the user name and course name match an existing record in your UserInfo
table in the database. Since the student accounts were not set up
properly, you need to follow two simple steps to protect (or sort of
protect) your MySQL password:
- Hard-code the password into your program.
- Set the permissions of your .java file to -rw-------
using the Unix command "chmod 600 YourJavaFile.java" or "chmod go-rwx
YourJavaFile.java". Note that the permission of your .class file should
still be -rw-r--r-- or -rw-rw-r-- in order for Tomcat to access it.
[Q&A] (5pt) Please write down your answers to the following questions on a piece of paper.
About Unix
1. What Unix command do you use to display the permissions of a file or a directory on the server?
2. Explain the permissions of the file demo.sql and the directory public_html/ as shown below:
-rw-rw-r-- 1 csun
csun 494
May 3 07:45 demo.sql
drwxr-xr-x 3 csun
csun 4096 May 6
13:46 public_html
3. In order for Tomcat to access a directory under your home directory
(e.g. $HOME/public_html), what permissions should that directory have?
4. In order for Tomcat to access a file under your home directory (e.g.
$HOME/public_html/WEB-INF/classes/Shop.class), what permission should
that file have?
5. Which Unix command do you use to change the permssions of a file or a directory?
6. What does the Unix command man do?
More about JSTL
1. Read the JSTL documentation about <c:forEach> and explain the difference between the following two lines of code:
- <c:forEach begin="0" end="3" step="1" var="i">
- <c:forEach items="ttt.board" begin="0" end="3" step="1" var="i">
[Exercise]
Import your product info files from HW3 into your MySQL database. Write
a JSP to retrieve and display the product information from the database.