Tomcat
is the servlet-capable web server that we will be
using to execute web applications. I'll leave my installation of tomcat
running on sf08.cs.umb.edu (on port 11600) for your experimentation. You can look at this tomcat's files at ~eoneil/cs639/tomcat-6.0 in the UNIX filesystem.
My directory ~eoneil/cs639 has the tomcat
installation, made following the student instructions. In other words, I'm
pretending to be a student in the class, but letting you see the results,
whereas when you put subdirectories under your own cs639 directory, noone else in the class may see them. IMPORTANT: Don't
ever change permissions on your cs639 directory.
1 HTTP.a. Use a browser to
look at the tiny HTML test page at www.cs.umb.edu/cs639/test.html. Follow its
link to the test page served by my tomcat, and then follow the link there.
For each generated request-response cycle, give the connection (server,
port) and GET command that was issued by your browser.
b. At the command line in UNIX or Windows, do the command "telnet
www.cs.umb.edu 80" to connect your keyboard and screen to our departmental
web server, which runs on host www.cs.umb.edu on TCP port 80, the normal HTTP
port. You will get no output from it immediately. Instead, it is waiting
for your request. Type "GET /cs639/test.html
HTTP/1.0" followed by two carriage returns. (Use HTTP
1.0 even though browsers use HTTP 1.1, so the web server expects less from
you.) You may have to type this without seeing anything on the screen--after
all this is set up to talk to programs, not real users. The second
carriage return (making a blank line) tells the web server that you are done
with the request. Then it will return the HTTP response: header followed by the contents of the test page, and then drop
the connection. Capture the output and record it in your homework paper,
including the message about the connection going away. Indicate the
header and contents.
c. Note that HTTP is stateless. Once the
HTTP response is sent off, the web server forgets all about that request and
goes on to the next one. List the sequence of server, host connections
and HTTP requests and responses that happen when a browser goes to access a
static web page (imagined) at www.cs.umb.edu/cs639/test2.html with two images
with relative URLs image1.jpg and image2.jpg.
2. Try out tomcat, accessing just HTML pages to start.
a. Browse to http://sf08.cs.umb.edu:11600
to see the "root" page. You are using TCP port 11600, on
which tomcat is listening on sf08. You should see a picture of a tomcat and
some text about the Apache Tomcat project. Also links,
including to some JSP examples of interest. Then browse to http://sf08.cs.umb.edu:11600/cs639/index.html
to see my little index.html page--you will be making a similar one for
yourself. This file index.html is situated at file path
~eoneil/cs639/tomcat-6.0/webapps/cs639/index.html.
You are welcome to look at it in the UNIX/Linux filesystem
The webapps directory
is the root directory of this website served by my tomcat. That's
why the URL, http://sf08.cs.umb.edu:11600/cs639/index.html uses the part of the
file path after webapps, the local path.
Give the UNIX command you used to display this file while cd'd to your own login directory. Also the UNIX
command to display the other page involved in problem 1a.
b. Use telnet to access the same file "telnet sf08.cs.umb.edu 11600",
followed by "GET /cs639/index.html HTTP/1.0" and record the response.
3. 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://....
4. Install tomcat on Linux, following the instructions linked from the class web
page. As instructed there, make a little HTML page accessible at http://sf08.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.
5. 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.
6. Another javac command. Suppose you are cd’d
to the src directory of your pa1b project. Give the javac command to compile all of your sources under src, placing their output .class files under
pa1b/build/classes, i.e. ../build/classes from src.