How to access Tomcat from another computer?

前端 未结 6 1014
小鲜肉
小鲜肉 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: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)

提交回复
热议问题