Custom Tags
1. Make a random number tag that inserts a random
number between 0 and 1 into the page.
2. Make a random number tag that inserts a random
integer between 0 and some specified number.
Servlet/JSP Integration and the
MVC Architecture
1. Write a servlet that
generates a random number, puts it in a bean, and forwards it to a JSP page
that displays it. Use request-based bean sharing.
Hint: you might want to start by simply forwarding
from an empty servlet to a simple JSP page that doesn’t
use beans. Then, once you have the RequestDispatcher
part working, you can go back and have the servlet
store the bean object (request.set-Attribute) and
have the JSP page read it (jsp:useBean with
scope="request").
2. Write a servlet that
reads the firstName and lastName
request parameters. If they are both present, it forwards the user to a page
that displays them. If either is missing or is an empty string, it uses
previously seen values from that client. If values are still missing after
that, it forwards the user to a page that tells them which parameter is missing.
Use session-based bean sharing.
3. Write a servlet that uses
a request parameter to determine the desired size of a prime number. If the
user asks for a particular size, it should create and store one of that size.
If no size is specified, the system should use the previous prime number (if
there is one). Either way, it should forward the user to a page that displays
the number. Use application (servlet context) based
bean sharing.
JDBC
1. Make a servlet that
displays a bulleted list of the names of all shipping companies used in the Northwind example. (Table name: shippers; column name:
Company-Name — see the second of the screen shots from “Using Metadata”).
2. Make an HTML form that collects a last name. Send
the name to a servlet or JSP page. If there is an
employee with that last name, show full details on him or her (just show the
first employee if there are multiple people with the same name). If there is no
employee with that last name, say so. See the screen shot from Access for
details on the column names (table name: employees; column names firstname, lastname, title, birthdate).
3. Make an HTML form that collects three values: a
table name, a number of columns c, and a number of rows r. Send the data to a servlet or a JSP page. Display an HTML table containing the
first c columns of the first r rows of the designated table. Be sure to handle
the case where c or r are too big.