CS639 hw2  HTTP, using Tomcat, installing Tomcat on UNIX, servlets

Due Thurs, Feb. 28,  in class, on paper

1. (Optional, done in cs636) Read this servlet tutorial, specifically the sections "Overview of Servlets and JSP", and "First Servlets".  We will be using servlets, not JSP, but since JSP turns into servlets, the subjects are very close.  Try out the first two servlet examples that come with the tomcat installation (the ones listed below, perhaps others too)  using my tomcat server, following the link from the root page described in 2a.  These were discussed in class with a handout. 
a. Try Hello World. Get your browser to say what encoding is in use for the output page and record it.  Also, use telnet to get this page so you can see the header, and record the Content-Type from the header.  Explain how this encoding is specified in the servlet.
b. Try Request Info. The only object in use here is the HTTP request object.  What methods of request's class are being called to find the "Request URI"? What is the value of the Request URI? Note that this use of the term “URI” differs from the use in REST, where it would mean the whole string http://....

2. Install tomcat on Linux, following the instructions linked from the class web page.  As instructed there, make a little HTML page accessible at http://users2.cs.umb.edu:NNNNN/cs639/index.html, where NNNNN is the first port assigned to you, when your tomcat is running.  This installation for your own tomcat will be in your cs639 directory, protected from other student's access.  Don't worry, tomcat will be running under your user id, and will be able to read everything it needs.  Again, don't ever change permissions on your cs639 directory.  If you took CS636 last term, you can “mv cs636/tomcat-6.0 cs639” to get it into its new spot.  Clean out the old cs636 projects too. Or just reinstall it.

3. Give XPath expressions for the following queries

Using book.xml:

a.       the titles of all top-level sections

b.      the title of the section with a figure titled “Examples of Relations”

c.       the source attributes of images of all figures 

d.      all first sections (at any level)

on the XML from pa1

e.       all the non-nested nonstatic class method names

f.       all the first-level nested class nonstatic method names

g.      all the method names

h.      all the class names of classes that have a static method called "main".

To test them, see $cs639/xpath for TestXPath and more info in README.

4. Namespaces. See $cs639/validate/clocks.xml for the XML of Example 1.6 in Harold, and clocks1.xml for added DOCTYPE and clocks2.xml for nonNameSpace XSD linkage (referred to on pg. 40). The needed DTD order.dtd and XML schema order.xsd are there too.

a. Use Counter to validate these XML docs.

b. Add a namespace as shown in Example 1.7 in file clocks3.xml.  Note that the URI in use here does not have to resolve to anything, just be a unique ID. Check the well-formed-ness using Counter.

b. Then try to validate against the .xsd, using –schema for specifying the schema (doesn’t work).  You need to modify the schema to work with the namespace.  See book.xsd vs. book1.xsd in $cs639/validate-ns. Compose order1.xsd and show that it works.

c. Put the linkage to the schema in the .xml, for clocks4.xml.  You can no longer use “xsi:noNamespaceSchemaLocation”, but rather need the namespace version of this. See $cs639/validate-ns/book5.xml for an example.

d. Indicate how the XML would look with “xmlns:c = …” instead of “xmlsn = …”. For an example, see book6.xml. You can just show the first few lines.

5.  (Optional, done in cs636) Intro to unit testing. Read the JUnit docs linked to the class web page under Resources>JUnit4. Look at the unit tests in orderService. In Eclipse, pull down Help, select Help Contents>TestingApplications>Testing with JUnit, and read about Creating JUnit tests. To run them, just right-click on the file, package or project, and Run as..>JUnit test. Report on your success adding another test to orderService and running all the tests, from eclipse and also using ant directly.