How to access Tomcat from another computer?

前端 未结 6 992
小鲜肉
小鲜肉 2020-12-31 06:35

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

相关标签:
6条回答
  • 2020-12-31 07:10

    Your friends can access your website only through a public static ip.

    So you will have to host your application on a servlet container like tomcat. And then either

    Make your tomcat ip same as public ip : This can be done if you have a control panel or admin control.

    or

    Internally redirect request from your public ip to your tomcat ip/url. This you can do if your public ip is bind to a web server like apache.

    0 讨论(0)
  • 2020-12-31 07:13

    If you are using Windows 10, allow Tomcat to communicate through the firewall.

    1. One way would be Control Panel -> System and Security -> Windows Firewall -> "Allow an app or feature through Windows Firewall" -> "Change settings" -> Enable Private and Public for "Commons Daemon Service Runner" (if not present: "Allow another app..." -> Chose tomcat#.exe in Tomcat bin directory, where # will be the tomcat version number)

    2. Add a firewall exception for javaw. In Windows 10, that is the steps above up to "Change settings", followed by: Find Java(TM) Platform SE binary with a path to javaw (add as above if not present) -> Enable Private and Public for it.

    0 讨论(0)
  • 2020-12-31 07:16

    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!

    0 讨论(0)
  • 2020-12-31 07:30

    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:

    • How To Forward Ports on Your Router


    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

    • The official Apache Tomcat documentation
    • Beginning & Intermediate Servlet & JSP Tutorials
    • Tomcat for beginning Web developers (PDF file)
    0 讨论(0)
  • 2020-12-31 07:30

    Just Enable Firewall port for tomcat on your windows machine.

    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.

    0 讨论(0)
  • 2020-12-31 07:31

    I had the same problem in my windows 8 OS, I just have added an exception to port on which the tomcat apache was running.

    for adding exception to port use the following step

    1. Open Windows Firewall by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type firewall, and then click Windows Firewall.

    2. In the left pane, click Advanced settings. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

    3. In the Windows Firewall with Advanced Security dialog box, in the left pane, click Inbound Rules, and then, in the right pane, click New Rule.

    4. Now select port and click next, now enter your port in specific local ports OR check on All local port.

    5. Select your preferred setting on next two panel, and the last give your Inbound rule.

    0 讨论(0)
提交回复
热议问题