|
| Sem. Project |
| 1. HTML |
| 2. HTTP |
| 3. JavaScript |
| 4. Servlets |
| 5. JDBC |
| 6. Tomcat |
| 7. Web Client |
| 8. Web Server |
| 9. Security |
| Miscellaneous |
![]() |
|
Assignment - 08
General Requirements
Assignment 8 consists of implementing the "ServiceHandler" class for Web Server.
The purpose of this assignment is threefold. First, to gain an
understanding of the fundamental task of the Web Server. Second,
to learn the precise format of the HTTP request and response messages
as well as to understand the importance of the data within the message structure.
And thirdly, to solidify the significance of the web server's document root.
Thus, learn as much as you can about the message structures and experiment
with as many headers as possible. Also, experiment with different document
roots, along with making requests for: files, directories (with and without
html files), etc.
Please follow these overall instructions:
Setting up and Testing Development Environment
Compiling ServiceHandle.java
compile ServiceHandler.java
where:
compile = compiler batch file
ServiceHandler.java = name of program
Executing the web server
startup [package_name]
Configuring the web server
**Important**
The three problems 1-3 described in this assignment are progressive;
meaning the previous problem(s) is needed in order complete the next
problem. Since this the case, I will only be looking at your
final problem, as it will imply you were able to complete the
previous ones. Although I will only be looking at your final
submission, it is highly reccomended that you keep separate
working versions of each of your programs for back-up and solid
development techniques. [simply rename it to ServiceHandlerV1, etc.]
On your web page indicate where your work can be found, along
with the last problem you were able to complete.
For example:
Problem 1: Creating a valid status line
Part A:
Part B:
On your web page, briefly describe your tests and corresponding
results. Explain why you got the results you did.
Problem 2: Creating a fully qualified resource name
Part A:
Part B:
On your web page, explain the relationship and significance
of the document root and the request's resource name.
Problem 3: Get the resource and send to client
Part A:
Compile and test the changes.
Part B:
Problem 4: Web Server Enhancements
On your web page, describe how you would change the web server program to handle serving (returning) binary files such as jpg or gif, in addition to the html pages it can currently serve.
What to hand in:
Questions ? ?
To help you work on your own PC:
Additional Thoughts
Questions are sure to arise about where you 'have' to do your work. The answer
is anywhere you choose, with the caveat that you are responsible for
making sure your student# directory is completely workable on the due date. In other
words, when I test your web server, all I will do is execute the startup command and
check from that point. Fair warning: NO second chances here!!
Sample ServiceHandler Code
package studentLastName;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.*;
import java.util.*;
import net.rvpakala.service.*;
import net.rvpakala.httpServer.*;
public class ServiceHandler extends ServiceProcessor
{
public ServiceHandler()
{
}
// Process GET requests
public void doGet(HTTPRequest request,HTTPResponse response) throws IOException
{
super.doGet(request,response);
//----------------------------------------------------
// The following sample/psuedo code is to:
// (a) illustrate generically what you are to do
// (b) help you recall the super class methods
// available to you
//
// String responseLine1 = "<html>" +
// "<head>" +
// " From HTTP Server Code" +
// "</head>" +
// "<body>" +
// " this is my message" +
// "</body>" +
// "</html>";
// String responseLine2= "status line detail";
//
// response.getWriter().write(responseLine1);
// response.getWriter().write(responseLine2);
//
//
// ** NOTE: you "must" flush and close the Writer as
// well as close th Reader, when you have completed
/// creating your response message. This is shown in
// the next 3 lines:
// response.getWriter().flush();
// response.getWriter().close();
// response.getReader().close();
//
// -------------------------------------------------------
}
}