Apache Tomcat is a Servlet/JSP container and used to deploy dynamic Java contents like JSPs and Servlets. Tomcat has some web server capabilities, however it is not a full blown web server to serve high traffic web sites. In the meantime Apache HTTP server is a full blown web server. So in general Tomcat is configured along with Apache HTTP server to maintain a healthy web site with dynamic content. This article will cover the steps of configuring HTTP server and Tomcat connection, however this will not discuss installation details of Apache or Tomcat.
Followings are the short names used to denote folders used in this article.
For version 2.2.10 of Apache HTTP; correct connector version is 2.2.4 (available here). Make sure to download the correct version, as incorrect version may result in errors.
Now the downloaded mod_jk module must be configured in Apache HTTP server. First rename the above downloaded file say mod_jk-1.2.26-httpd-2.2.4.so to "mod_jk.so". In Apache server, module files are stored under %APACHE_HTTP_HOME%\modules folder. Now copy the mod_jk.so file into this folder.
Then open the HTTP server configuration file named httpd.conf. It's located in %APACHE_HTTP_HOME%\conf folder. This file has a number of lines used to load Modules starting with "LoadModule ". Add the following line below these lines.
Now the downloaded mod_jk module is added into Apache server.
Pay attention to the above port 8009; this is the port defined inside %CATALINA_HOME%\conf\server.xml file as follows.
If the port in AJP 1.3 connector section of Tomcat is different than 8009, change the above workers.properties file to match that.
Now we need to configure the workers.properties file in %APACHE_HTTP_HOME%\conf\httpd.conf file. For that add the following lines after the line that we added into httpd.conf in a previous step.
Now everything is setup. However still we have not yet defined the important part; which user requests to be forwarded to Tomcat server from Apache server.
First one will send all requests for a web application named "myProject" to Tomcat while the second will send all requests ending with ".jsp". The third line configures for all requests ending with ".do" (many use .do extension with Struts actions).
Add required configuration lines as above into httpd.conf (just after the lines we added in above steps).
Now Apache will direct all these request to Tomcat (running on a different port) and serve the client smoothly.
Related Article: How to change Tomcat port
System Requirements
- Apache HTTP server installed
- download from here
- we used version 2.2.10 for this article
- Apache Tomcat installed
- download from here
- we used version 5.5 here
Followings are the short names used to denote folders used in this article.
- %APACHE_HTTP_HOME%
- denotes Apache HTTP Server installation directory. In our testing machine, it is "D:\ASF\Apache"
- %CATALINA_HOME%
- Tomcat installation directory; for example: "D:\ASF\Tomcat"
Connection Configurations
The connection between HTTP server and Tomcat will be done using Apache Tomcat Connector module named mod_jk which is configured inside Apache HTTP server. For that first download the correct version of connector from here.For version 2.2.10 of Apache HTTP; correct connector version is 2.2.4 (available here). Make sure to download the correct version, as incorrect version may result in errors.
Mod_jk configuration
Now the downloaded mod_jk module must be configured in Apache HTTP server. First rename the above downloaded file say mod_jk-1.2.26-httpd-2.2.4.so to "mod_jk.so". In Apache server, module files are stored under %APACHE_HTTP_HOME%\modules folder. Now copy the mod_jk.so file into this folder.Then open the HTTP server configuration file named httpd.conf. It's located in %APACHE_HTTP_HOME%\conf folder. This file has a number of lines used to load Modules starting with "LoadModule ". Add the following line below these lines.
LoadModule jk_module modules/mod_jk.so
Now the downloaded mod_jk module is added into Apache server.
Tomcat Server Information
We need a new properties file to store details about the Tomcat server. Create a new file named workers.properties inside %APACHE_HTTP_HOME%\conf folder with the following content.worker.list=localTomcat
worker.localTomcat.host=localhost
worker.localTomcat.port=8009
worker.localTomcat.type=ajp13
Pay attention to the above port 8009; this is the port defined inside %CATALINA_HOME%\conf\server.xml file as follows.
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
If the port in AJP 1.3 connector section of Tomcat is different than 8009, change the above workers.properties file to match that.Now we need to configure the workers.properties file in %APACHE_HTTP_HOME%\conf\httpd.conf file. For that add the following lines after the line that we added into httpd.conf in a previous step.
JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
Now everything is setup. However still we have not yet defined the important part; which user requests to be forwarded to Tomcat server from Apache server.
URL Patterns
Following is the format of those configurations.JkMount <URL_PATTERN> <WORKER>
- <URL_PATTERN> - the url pattern that you need to forward to Tomcat
- <WORKER> - the worker name defined in workers.properties file.
JkMount /myProject/* localTomcat
JkMount /*.jsp localTomcat
JkMount /*.do localTomcat
First one will send all requests for a web application named "myProject" to Tomcat while the second will send all requests ending with ".jsp". The third line configures for all requests ending with ".do" (many use .do extension with Struts actions).
Add required configuration lines as above into httpd.conf (just after the lines we added in above steps).
Setup Completed
Now try the URLs of your application as follows (using Apache port number, rather than Tomcat port number). We assumed Apache HTTP server is running on port 80. Following as some sample urls for the above configurations.http://localhost/myProject/
http://localhost/testApp/main/admin.jsp
http://localhost/strutsApp/login.do
Now Apache will direct all these request to Tomcat (running on a different port) and serve the client smoothly.
Related Article: How to change Tomcat port





In Java Servlets API, both HttpServletRequest and HttpServletResponse interfaces (in javax.servlet.http package) provide methods to programatically manipulate HTTP headers. There are a number of standard HTTP headers exchanged between a web server and a client (eg: a browser). "Content-Type" is a commonly used header (which is used to specify MIME type) in Servlets. In this article we are discussing how headers are read/written with Servlet classes.
Now you will see a small icon in status bar (bottom right corner) as shown here. This is the redirector extension we installed above. You can enable/disable this extension just by clicking on this icon.
Now we have to fill 3 options in this new redirect box.
"This account is open in 1 other location at..." Gmail user interface provides this message when your account is used in multiple locations simultaneously. One of the most important and interesting security feature that any web mail service would wish to provide. I suppose Gmail is the only web mail service that has this type of security feature (let us know if any other does). Users become aware of any misuse of their Gmail accounts.
We are not highlighting the weaknesses by neglecting effort made in providing this feature. However, as an improvement; active sessions count can be shown at the top bar; so that all users will notice the multiple session usage. However this should be displayed only when multiple sessions are active.
Sun has suspended their NetBeans IDE DVD Starter Kit distribution program indefinitely. Yes, you read it correctly; they have done it. So many developers used to get most of Sun (free) products through the distribution program. Students with less bandwidth (in some colleges & universities); specially users without Internet access to home computers are fond of this service as NetBeans DVDs are freely delivered to their hands at no cost.
Spring framework can instantiate and bind (called loading) related Java objects (called beans) according to a given configuration. An XML file can easily be used to define these bindings. Spring framework supports two different types of loading methods; lazy loading and pre-loading respectively managed by BeanFactory and ApplicationContext containers.
Locate the "Forbidden reference (access rules)" option under "Deprecated and restricted API" section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to "Error" which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.
Tab is not another thread running inside the browser process; there is a separate process per tab. Even if one tab crashes, the rest of the tabs will be running as nothing happened; which was not available in Firefox. This is one of the most interesting features.
Some of the fonts are not displayed smoothly as Firefox used to do. Above image shows how the same content is displayed in two of these browsers.
May be it is not a must to have a XML viewer in a browser, but we are used to it. Firefox and IE both have good XML viewers, but Chrome lacks it. Similar to this Opera and Safari also do not have this feature. Many people happened to work with XML files every day and having an XML viewer in the browser is an added advantage.
Google Web Toolkit (GWT) and Java Servlets used in one web application. This tutorial will take you though the steps of developing a simple web application with Google Web Toolkit and J2EE Servlet Technology. The application will have a servlet on server side and one web page.
It will contain a Java class (Entry point class), a HTML page and a XML file (called Module XML). This module xml file will also be discussed later. For the time, better note the path to this file: org/kamal/hello/HelloWorld.gwt.xml.
Create a folder named "GWT-Sample" inside $CATALINA_HOME/webapps and copy "www\org.kamal.hello.HelloWorld" and "www\WEB-INF" folders into that "GWT-Sample" folder (shown above). Now everything is completed.
Now you will see the web page with the label text and button as shown in the image. Play around by clicking the button to see different messages coming from the server. The web page will not be re-fetched from the web server, but only the text of the label will be refreshed.