Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Tomcat from another computer?

I have an JSP website which I want to share with my friends. We all are using a same internet resource. We have a common static IP:49.204.14.98(My Public IP). We are almost 40 users sharing the same resource. I have IP something as 192.168.0.120. When I try connecting to 192.168.0.120 it is not able to connect. Please suggest me how to make my server accessible to other PCs.

I am not the administrator and I don't have access to the router settings.

I saw this link link but it is not related to my problem

like image 540
NewUser Avatar asked Dec 26 '12 06:12

NewUser


People also ask

How do I access Tomcat remotely?

To access the server, use its external IP address (found on the hands-on lab overview page) in the URL bar of a web browser, then append :8080 to it. Test to ensure you are unable to access the Host Manager App on the Tomcat GUI.

How do I connect to a local Tomcat server?

Goto Windows Firewall->Advanced Settings->Inbound Rules. In the Right side click on New Rule->Then select Port from dialog box and Next->Then type port "8080" (As by default Tomcat run on this port) and Next->Then select "Allow the connection"->Next->Give a Name ->Finish.

How do I make my Tomcat server public?

The general explanation would be to open the port on your firewall and put some kind of port forwarding on your router (port 80 to port 8080 would be expected). You can also change the port Tomcat is expecting connections from 8080 to 80, so you should only forward port 80 to port 80 on the inner network.


2 Answers

Like @informatik01 wrote, "If all your friends are on the same LAN (Local Area Network) as you are (and you say they are), the they can access your web application using the above URL. http://192.168.0.120:8080/Your_App_Name/some_path/some_file.jsp"

What OS are you using? Have you made any changes to server.xml in $CATALINA_HOME/conf?

Try accessing it locally first, then try it from one of your friends computers. If it then fails, try and shutdown the firewall on the same machine as is running the tomcat instance. Depending on its configuration it may prevent incoming connections on the default port 8080. If that was the issue, reactivate the firewall and open the desired port 8080 for http traffic.

Get to know the logs, they are usually located in $CATALINA_HOME/logs/, have a look in catalina.out for example. If you´re unsure weather the server is up and running or not and whatever issues may´ve arisen, thats the best place to check. There it will state which webapps it finds and if it was successfull in deploying them. You can also go to the server root with your browser at localhost:8080 and check if you get the welcome screen.

Good luck!

like image 56
Gesias Avatar answered Sep 19 '22 08:09

Gesias


If you are using Apache Tomcat, then by default applications deployed to it are accessible on port 8080.

So IF you have already deployed your web application to Tomcat in a proper way, AND you have started the Tomcat server, then you can access your application (website) like this:

http://localhost:8080/Your_App_Name/index.jsp

Instead of localhost, you can use 127.0.0.1, or your private IP address 192.168.0.120 like this

http://192.168.0.120:8080/Your_App_Name/index.jsp

Instead of Your_App_Name use the name of your deployed application (application context), and index.jsp is here as an example.

IF all your friends are on the same LAN (Local Area Network) as you are (and you say they are), then they can access your web application using the above URL.

http://192.168.0.120:8080/Your_App_Name/some_path/some_file.jsp

IF they are outside your LAN, then you have to configure port forwarding on your router. And to do that, of course, you need to have access to it. Then they will be able to access your web application using your public IP and the port as it was configured while setting port forwarding.

Here is a very good article with pictures:


By the way, if you have properly installed Apache Tomcat and started it, then you should be able to access it like this:

http://localhost:8080

Useful resources

like image 24
informatik01 Avatar answered Sep 20 '22 08:09

informatik01