This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Tomcat and the fly likes why we need connector for Apache and Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "why we need connector for Apache and Tomcat" Watch "why we need connector for Apache and Tomcat" New topic

why we need connector for Apache and Tomcat

may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
People can also use localhost:8080 directly in their applet to use servlet on Tomcat, so why we still need to so be troublesome to load and mod in Apache, configure Httpd.conf and use connector?
Or just want to make the webaddress look beautiful?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Actually, tomcat can be configured to respond on port 80 as well, so you can remove the :8080 from the web address (and since 80 is the default http port, you can leave off :80 as well).

What this means though, is that for that IP, on that server, you cannot have Apache serving on port 80. So you're forced into a choice of using Tomcat, or using Apache, but not both.

The way around this is to use a Connector. Apache listens to port 80, and it forwards any requests that need to be, to Tomcat.

There have been *many* discussion both in this forum, and on the tomcat-user email list about this very topic ("Should I use a Connector with Apache, or Tomcat Stand-Alone?")

like this one

There are many reasons to just use tomcat
* ease of configuration
* don't need PHP/cgi/perl

There are many reasons to use Apache, connected to Tomcat through JK/JK2
* I need PHP/cgi/perl
* mod_rewrite
* multi-tier security considerations
[ June 02, 2004: Message edited by: Mike Curwen ]
may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
Yeah, I know web server default is 80 port, Tomcat default is 8080, Tomcat can be changed to 80 cos Tomcate can be webserver and application server.

I just think when I decide to use Apache as Web server on 80, Tomcat as application server to support servlet, I can use Tomcat to support servlet for Apache server without configuring the connector, just use localhost:8080 or X.X.X.X:8080 if I don't think it is troouble, so I don't need to load the JK or Webapp module into httpd.conf. I don't need to configure the server.xml.

Is that ture?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I wouldn't count on that. What if a firewall or router blocks 8080 specifically? Or only lets in 80, 23, and other well-known ports.

and also, it can't be "localhost", but I assume you're just using that as short-hand.

Applets are requested from the client, not the web server.

And while you *could* produce a mixed application that has parts *.html and parts /servlet and *.jsp pages, why would you ever want to keep track of remembering whether or not you had to put :8080 or not? That's what a connector is *for* !
may Lee
Ranch Hand

Joined: Nov 20, 2003
Posts: 68
The firewall reason makes sense!! That is ture, people maybe only open the know the well-know ports.

I know. localhost:8080 is just for test, for the client I need to put IP address with 8080

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17144

Port 80 is best, because unless you explicitly say otherwise, that's the one people's web browsers normally hit.

Whether you bring up Tomcat directly on port 80, or pipe it from an Apache (or other server) that's on port 80 depends on your needs and preferences, and, as mentioned, pros and cons have been discussed in depth here more than once.

Firewalls are another incentive to use port 80, though 8000-series ports are not blocked very frequently, since ports such as 8080 and 8008 are very commonly used as secondary service ports.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: why we need connector for Apache and Tomcat
jQuery in Action, 3rd edition