head 1.5; access; symbols IT1FALL00:1.3; locks; strict; comment @# @; 1.5 date 2001.03.27.20.33.02; author dbc; state Exp; branches; next 1.4; 1.4 date 2001.03.07.01.56.01; author dbc; state Exp; branches; next 1.3; 1.3 date 2000.10.20.18.18.09; author dbc; state Exp; branches; next 1.2; 1.2 date 2000.10.20.00.10.06; author dbc; state Exp; branches; next 1.1; 1.1 date 2000.10.18.18.19.25; author dbc; state Exp; branches; next ; desc @@ 1.5 log @Modified Files: hw4.html @ text @ Applications of Information Technology I: Homework 4, Spring 01

CIS 5930-04
Spring 2001

Homework #4

A Web-based User Interface using Servlets

Rewrite the client-server application you developed in the previous homework. Instead of using an applet front end to an RMI-based file server, the user interface should consist of a series of HTML pages with suitable forms, generated and handled by one or more servlets. A data file on the the Web server will be manipulated by the servlets.

The application should be deployed under a Tomcat server running on the port allocated for you on sirah, merlot, cabernet or pinot, in CSIT. The lectures give details on how to install and run the Tomcat server. Port allocations will appear on the course announcements page.

Submission of your Homework

Your submission should consist of files including
  1. A short description of your application, preferably in Microsoft Word, HTML, or plain text format,
which should be copied to the directory called /home/project/it1spring01/homework4/uid on sirah, where uid is your login ID. For this homework, the .html and .java source files you develop should be left in the installation directory for your Tomcat server, which should be in the home directory of your sirah account.

Grading

For this assignment, there will be a total of 20 points. Grading criteria are similar to Assignment 1. Some points will be assigned on the basis of apparent effort and uniqueness.


Resources and Tips

File Access from servlets

In general file I/O from servlet code is identical to Java file I/O from any other code. One thing to be careful about is using relative vs. absolute path names. If you use a relative path name for a file (e.g. "myfile") the accessed file will be in the current working directory associated with the Tomcat server. This is whatever directory you happened to be in when you started the server. This is unlikely to be what you really want, so instead you should open files using absolute path names (e.g. "/home/users/dbc/jakarta-tomcat/webapps/dbc/myfile").

Of course it is not good practice to "hard-code" absolute path names like this into your programs. Instead, use the method getRealPath() from ServletContext to convert a "uri" in the current context to an absolute path name, as in:

  ServletContext c = getServletContext() ;
  ... new FileReader(c.getRealPath("/myfile")) ...
This opens a file called myfile in the root document directory of the current context (i.e. the directory holding top-level HTML files for the context).

Deploying Tomcat

Download Tomcat from the Jakarta Project home page. For installation instructions, see the lectures, starting here.

Servlet examples

See the examples for the servlets lecture set, here.
Please send questions to Bryan Carpenter at dbc@@csit.fsu.edu.

@ 1.4 log @Modified Files: hw4.html @ text @d60 27 a86 1

Useful resources

@ 1.3 log @Modified Files: hw4.html @ text @d3 1 a3 1 Applications of Information Technology I: Homework 4, Fall 00 d9 1 a9 1

CIS 6930-01
Fall 2000

d12 2 a13 4

A Simple Client/server application

    d16 5 a20 1

    An RMI-based Server

    d23 7 a29 5 You are asked to write a client/server-based Java application, for manipulating entries in a text file. The text file should reside on a remote server, and the client program should run on a computer elsewhere on the Internet. Communication between client and server should go through RMI. d31 1 a31 12

    You should design a suitable remote interface through which the client can read and write to a data file on the server machine. For simplicity, limit the interface to operations for reading the whole file and writing the whole file (in single invocations). You may base your interface on the FileSource example discussed in the lectures, if you wish (you may only need to add one method for writing).

    It is recommended you run the server implementing this interface on sirah, merlot or cabernet in CSIT. d33 1 a33 2

    The client program may be one of: d36 3 a38 34 A Swing applet, adapted from the program you produced in Homework III. The JFrame should be converted to a JApplet, and calls to your remote interface should be added for reading from and writing to the data file on the server machine. To view your applet you will need access to an Internet-connected computer, probably with the Java 2 browser plugin installed. This will be discussed in the lectures.

  1. A Swing application, adapted from the program you produced in Homework III. Calls to your remote interface should be added for reading from and writing to the data file on the server machine. To run your client application you will need access to an Internet-connected computer, with the a suitable version of the Java Development Kit installed.
  2. A Java 2 application with a command-line based interface (no GUI). This interface should at least display all entries in the file, and give you an option to add new entries. It should include calls to your remote interface for reading from and writing to the data file on the server machine. To run your client application you will need access to an Internet-connected computer. If necessary you may telnet to one of the course hosts mentioned above (not the same host running the server!) and develop and run you client there. d40 8 a47 7 Option 3 is only recommended for people who do not have access to a computer equipped with the right software to make 1 or 2 possible, or people who did not complete Homework III. If you completed homework III, options 1 or 2 should be less work: this is supposed to be a relatively short exercise in getting an RMI based program running. It should not involve extensive new coding. d50 11 a60 9 To submit your homework, include d62 1 a62 5

    To submit the homework you should copy these files to /home/project/it1fall00/homework4/login/ on sirah, where login is your login id (user name) on this machine. d64 3 d68 1 a68 15

    If you write an applet, you are encouraged to deploy class files and data files in the directory /home/httpd/html/users/login/homework4/ on sirah, where login is your login id (user name) on this machine. You should then be able to view the applet at a URL of the form:

    http://sirah.csit.fsu.edu/users/login/homework4/...
    d70 2 a71 3

    Further advice may be added to this page as the submission deadline approaches ... a78 1 @ 1.2 log @Modified Files: hw4.html @ text @d84 2 a85 2 an RMI based program running. It should not involve extensive coding. d111 1 a111 1 You should then be able to view the applet at a URL: @ 1.1 log @Added Files: hw4.html @ text @d18 1 a18 1

    An RMI-based Server, with an Applet Front-end

    d21 5 a25 5 You are asked to write a Java application for manipulating entries a text file. The text file should reside on a server, and the program should have applet GUI front-end. The applet should communicate with a remote object running on the server, through RMI calls. The remote object should be responsible for file I/O. d28 6 a33 5 You are encouraged to adapt the GUI you produced in Homework III for this purpose. The JFrame should be converted to a JApplet, and you should design a suitable remote interface for reading from and writing to the data file on the server machine. d36 3 a38 6 The remote interface may provide "fine grain" operations for reading and writing individual entries, or it may only support reading the whole file or writing the whole file (as single invocations). In the latter case, the modified entries might (for example) be returned to the server when the browser leaves the Web page containing the applet. d41 45 a85 2 On the server you should start a remote object implementing this interface, preferably with an internal registry. d91 1 a91 1 a short document describing the application and program, and a96 1 For general guidelines, see the Homework II page. d106 2 a107 2 You are encouraged to deploy class files and data files in the directory d111 2 d115 3 a117 4 IMPORTANT: If you leave Java source files in this directory, please ensure they are not world readable. Later, if you wish, you may publish these files through this Web directory, but not until after d122 1 a122 1 Further advice may be added on this page as the submission deadline approaches @