Quiz 3

You are to write several files, the main one being, q3.servlet. This servlet includes code that check to see if the person is logged in and also if so logs their visit to the page in a database table along with the time. It also shows how many times the person has visited this page.

Here are all the files you need to create

q3login.html This generates a form asking for a loginid and sends the data to q3dologin.servlet

<html> <head><title>login</title></head> <body> <form method="post" action="q3dologin.servlet"> loginid: <input type="text" name="loginid"/><br/> <input type="submit"/> </form> </body> </html>

q3dologin.servlet If the loginid parameter is not #null, then this servlet logs the user in by evaluating

  (setAttribute request "login" loginid)
Note it doesn't require a password and doesn't do any authentication, it just trusts them. It also has a link to q3.servlet. <html> <head><title>login</title></head> <body> <form method="post" action="q3dologin.servlet"> loginid: <input type="text" name="loginid"/><br/> <input type="submit"/> </form> </body> </html>

q3logout.html This sets the session attribute "login" to #null and generates a link to the q3login.html page.

(servlet() (define a (getAttribute request "login")) (setAttribute request "login" #null) {[a] has been logged out. Go to <a href="q3login.html">q3login.html</a> to log in again} )

Next you need to write the following two files:

q3dbinit.servlet this creates the table q3UNETIDlog which contains two BLOBS: the loginid of the person visiting the page, and a timestamp of when the person visited the page (generated using (Date.)). Use your own UNETID in the name of the table ... This servlet also stores the request of the query in a variable r1 and then includes that variable in the response page, so we can see if there is an error.

q3.servlet this page does several things:

Good luck.

HINT: