13

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

3
  • Have you rented server on cloud?
    – rai.skumar
    Commented Dec 26, 2012 at 6:52
  • No I don't have a server. I have installed Tomcat in my system
    – NewUser
    Commented Dec 26, 2012 at 6:53
  • 1
    Software firewall? That would explain why localhost URL works but local-IP does not. Commented Dec 27, 2012 at 22:59

7 Answers 7

20

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!

3
  • I am able to access the page locally. I am not able to access it in the LAN. It says page not found. Do I need to disconnect from the Internet to access it locally?
    – NewUser
    Commented Dec 27, 2012 at 7:38
  • @Dibya No, you don't need to disconnect from the internet to access your web app locally. And when you access your site locally, YOU ARE actually on the LAN yourself, because LAN is Local Area Network. If it says "Page Not Found" it is actually a good sign: means the server is working. Just check the URL that you use ... Commented Dec 28, 2012 at 1:41
  • 1
    @Dybia like @informatik01 says then the firewall will not be the issue and the server is up and running and answering you. Can you post the URL that youre using for local access as well as the one youre friends computers using? If youre using the local IP like the example http://192.168.0.120:8080/Your_App_Name/some_path/some_file.jspthen it should work on your friends computers if it works on yours.
    – Gesias
    Commented Dec 30, 2012 at 3:39
20

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

8

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
5

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.

1
  • Thought port forward would be enough, but with the firewall rule it works now for me. Thanks :) !
    – BAERUS
    Commented Dec 20, 2018 at 16:50
0

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.

3
  • Can you please provide any resources form which I can learn how to achieve it?
    – NewUser
    Commented Dec 26, 2012 at 6:53
  • Do I need to have the admin control on the router?
    – NewUser
    Commented Dec 26, 2012 at 7:04
  • I have no idea about networking concepts. I am not able to understand these concepts is there any scope without understanding the concept can I just use it?
    – NewUser
    Commented Dec 26, 2012 at 7:15
0

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

Your Computer or mobile should be connected with same wifi

http://192.168.137.18:8283/servlet-student-crud-operation/studentRegister

Not the answer you're looking for? Browse other questions tagged or ask your own question.