[Q&A] (4pt) 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.
Suppose we want to implement a custom tag <foobar> using a Java class Foobar.java. The tag will be used as <cs320:foobar foo="a" bar="b"/>, or in other words, with two attributes but no body content. We also assume that the home directory of your account on the CS3 server is $HOME. 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 next section.
1. Which Java package(s) should you import in Foobar.java?
2. Which class should Foobar inherit from? and which method(s) should be overridden in Foobar?
3. What method(s) do you need to implement in class Foobar in order to support the two attributes foo and bar? Write down only the method header(s).
4. In order to compile Foobar.java, which class library should be included in the classpath? and where is this class library on the CS3 server?
5. Under which directory do you put the compiled Foobar class?
6. Under which directory do you put the TLD file for the custom tag?
7. The uri attribute in a TLD file is
8. An attribute element in a TLD file has five possible attributes: name, required, rtexprvalue, type, and description. All these attributes are fairly self-explanatory except rtexprvalue, which could be either true or false. What does this attribute do?
[Programming] Please upload
your files to CSNS.
The files should include all the source code, documentation, and an
HTML
file lab2.html,
which
contains a link to your JSP page on the CS3 server. Note that file
uploading will be open until midnight, but there will be a penalty of
2pt for work submitted after 8:40PM.
At the beginning of each CS320 class, I usually create a number of accounts on the CS3 server and assign them to the students in the class. In this exercise, you are going to help me automate this process.
[SQL] (2pt) Create the following two tables, Accounts and Students, in your database, using proper attribute type for each attribute:
Accounts:
|
Students:
|
Note that the Accounts
table contains a list of accounts that can be assigned to the students,
and the Students
table contains a list of students who have enrolled
in the class. Initially the CIN
fields of the accounts are null,
which means the accounts have not been assigned yet. Also for
simplicity we'll
assume that CIN is simply a 4-digit number.
For this problem, turn in a file lab2.sql which includes the SQL statements to create and populate the tables.
[JSP] (4pt) Create a JSP page GetAccount.jsp.
When GetAccount.jsp
is requested without any parameter, it displays the the following form:
Once
a user entered a CIN and clicked the Get
Account button, the application performs the following
operations:
For this problem you may use either Java beans or JSTL SQL tags to access the database. Using JSTL SQL is likely to be easier.
[Taglib] (extra credit +5pt) Create a custom tag <info> with one attribute students, which can be used to display some information about the students. In particular:Create a JSP page to show that the tag works correctly.