Download presentation
Presentation is loading. Please wait.
Published byMyles Blake Modified over 9 years ago
1
Field Trip #24 Setting Up a Web Server
2
Apache Apache is one of the most successful open source web servers In 1995 the most popular web server was the HTTP daemon Many webmasters had modified it and add fixes to it (patches) However, there was no way maintain a single distribution that contained them all A small group of webmasters were contacted
3
Apache, cont'd They came up with a scheme to provide a way that all of them could share their patches That is why the server is name Apache It is today the most popular web server
4
Tomcat Tomcat is an open source implementation of the Java Servlet technologies and JPS technologies A “servlet” is a small Java program that runs on a server It receives information through requests and outputs information to the user When you download Tomcat, it will come with the jar files you will need in order to create servlets
5
Connecting Apache to Tomcat In order to connection Apache to Tomcat, we will use a connector When a request for a servlet is received, Apache will forward that request to Tomcat We must configure Apache so that it can forward requests
15
This is the structure found in c:\Program Files (x86)\Apache Software Foundation\Apache2.2 c:\Program
16
The main configuration file for Apache is httpd.conf
17
These are the extra files containing optional configuration
18
The de facto port Apache uses is 80
19
All documents to be served out should be placed in DocumentRoot
20
The default file that will be served out is the DirectoryIndex
21
The error log is important
22
The Directory tags lets us specify if users can access files
23
Apache seperates some configuration files into the extra directory and we can choose if we want to include them
24
Tomcat To install Tomcat, we unzip the file containing Tomcat We will extract this into c:\Users\Public\tomcat C:\Users\Public is open to everyone We also create a directory called connector under tomcat, and there we place the file mod_jk.so
25
These are the configuration files found in tomcat\conf
26
This is found in tomcat-users
27
This is an important file. It creates a worker that will be used to executes the servlets we request
28
We have to modify the server configuration file so that it uses the same port specified in worker.properties
29
This file allows us to connect Apache to Tomcat. We load the connector, specify the workers file, specify the log files, and mount directories on the worker. This means that requests for servlets in those locations is passed to the worker
30
Creating a Basic HTML Page We can use an editor like notepad to create a basic html document A simple document can start with an tag In the section, we can specify the title In the section, we specify the content
31
Creating a Form A form begins with the tag We can include text fields for the user to input information with the tag We need to include at least one submit button We finish the form with
32
Creating a Servlet A Servlet is created by creating a subclass of javax.servlet.HttpServlet In this class, if we want to support the GET method, we implement the doGet method If we want to support the POST method, we implement the doPost method
33
CLASSPATH In order to compile the servlet, you need to make sure that servlet-api.jar is in your CLASSPATH CLASSPATH is a list of directories that are searched for classes In order to include a jar in the CLASSPATH, you list the absolute path including the jar file name
34
A Simple Servlet
35
The GET and POST Methods The GET method allows you to access the servlet with requests that look like http://.../?name=x The POST method allows you to access the servlet as the request of a post and the information is not visible In order to access the query, you can use the method getParameter that you call on an HttpServletRequest object
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.