aspose file tools*
The moose likes Tomcat and the fly likes Basic Tomcat Question: Change Port 8080? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Basic Tomcat Question: Change Port 8080?" Watch "Basic Tomcat Question: Change Port 8080?" New topic
Author

Basic Tomcat Question: Change Port 8080?

Jim Rosenberg
Greenhorn

Joined: Oct 14, 2009
Posts: 11
I have Tomcat installed on a shared sever. If I go to mysite.com/test.jsp it works. It also works if I go to mysite.com:8080/test.jsp. When I installed JForum, it uses the web.config file to map URLs to servlets. Those mappings quit working when I leave off the port 8080. Is it possible to get them to work on port 80 (Apache is also installed) without having to do a mod_proxy, or does does the JSP files work but the servlets do not?
rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
In conf folder there will be a server.xml file
you need to change port there. you will find it if you look into it.
Jim Rosenberg
Greenhorn

Joined: Oct 14, 2009
Posts: 11
Apache is also installed, and it's on port 80. Isn't changing the port number by itself not the solution (plus it won't even work since that's Apache's port)? I thought I had to do something where Apache takes the requests, but knows it's for Tomcat, the same way the JSPs work.
rewati raman
Ranch Hand

Joined: May 22, 2010
Posts: 62
Tomcat comes with apache. Apache will take the request and forward it to tomcat if tomcat is needed. why do you need another apache.
I think stopping apache and restating tomcat will do your work.
Jim Rosenberg
Greenhorn

Joined: Oct 14, 2009
Posts: 11
It's on a shared server. Apache is for the rest of the sites on that server, and then Tomcat is for 2 sites. I was told running Tomcat for all of them would be too resource intense, especially for those that don't actually need Tomcat.
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Jim,

Not that it matters much at this point, but what version of tomcat are you using?

If all you want to do is run JSPs, then you only need Tomcat. You don't necessarily need Apache + Tomcat.

In Tomcat's serverl.xml, you can change the port of Tomcat from 8080, to just 80. You can't have Apache and Tomcat listening on the same port, so if you want to run JSPs on port 80 using Tomcat, without configuring anything else for Apache, then turn off Apache.

Tomcat and Apache are two different products, you sound like you already know this, but just wanted to make you aware of that.

Who told you running Tomcat for HTTP would be too resource intensive? Did you read that somewhere on http://tomcat.apache.org or is that second hand info?


Thanks, leo
Jim Rosenberg
Greenhorn

Joined: Oct 14, 2009
Posts: 11
I am using Tomcat 5.5.28. I actually want to run servlets on one site, but am not too thrilled about redirecting all incoming requests to port 8080. The server uses cPanel, and Tomcat was installed with EasyApache. cPanel has an "Install Servlets" option for domains. When I choose a domain, it shows a warning message about servlets being resource intensive, and that I can only install them on about 100 domains.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

When you type a URL into a browser's navigation bar - or use any other URL-based reference to a website for that matter - the URL is parsed into its components. One of those components is the server/domain name. This name is then looked up in the "telephone book" of the Internet: DNS.

DNS entries only contain IP addresses, not port numbers. So if you make a request to a a server, the port name selected will be 80 for HTTP requests or 443 if it's an HTTPS request. If you want any other port, you must explicitly ask for it using the :port#" part of the URL. That's a function of the client (your browser), regardless of how the server was configured.

In general, complex websites will use something like Apache as the master dispatcher for all incoming URL requests. Apache will then analyze the URL and send it to a suitable handler. For Tomcat requests, that means that it will route the request via mod_proxy or something similar from the Apache server to the Tomcat server.

Although it might seem simpler to route directly to Tomcat, there are reasons why the Apache-to-Tomcat approach is preferable.

One of them is port conflicts. Since only one app can hold a port for listening, if Apache holds Port 80, Tomcat can't have it.

Another is security. On many systems, only root applications can open ports numbered below 4096. Apache can start as root and then switch to a less-privileged identity to protect itself and the system, allowing it the benefits of being able to listen on port 80 yet run unprivileged. Tomcat cannot do that. It would have to shed its write-once/run-anywhere abilities to do so, since OS-specific functions are required to do that.

Servlets ARE resource-intensive compared to say, PHP. However, bypassing Apache won't make them any less resource intensive. The whole point of servlets - and J2EE - is to be able to do resource-intensive processing.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jim Rosenberg
Greenhorn

Joined: Oct 14, 2009
Posts: 11
After poking around and Googling stuff, I found that when Tomcat was installed, it installed JkMount. When servlets are added to a domain, the /*.jsp rule is added to JkMount. That's why JSPs work without the port, but the servlets do not. I added the jforum directory, and now everything is working.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic Tomcat Question: Change Port 8080?