0

I'm new to tomcat and servlets. So I'm trying to test a simple jsp page on my tomcat 8 container. When I open the index.jsp file from localhost or 127.0.0.1 it works fine i.e. index.jsp page displays html as well as outputs the jsp code results. But when I run it through the pc's ip address(which is 192.168.1.100 on the local network), the browser displays the html but the jsp code is totally ignored. Here's a part of index.jsp :

</head><body>
<% 
    out.print("<h2>Hello, I'm running!!</h2>");
%>
<header><h1>The Real Thing</h1><h4>Vote or die!</h4></header>
<main>

I've even changed the tomcat web.xml's welcome-list, putting index.jsp before index.html but it's not working. So, if localhost is running the jsp code from index.jsp then why does the local network ip address not running the jsp code?

Any help would be appreciated.

NOTE : I deleted the index.jsp from /var/lib/tomcat8/webapps/ROOT/ but 192.168.1.100 is still displaying the web page while localhost is giving 404 page not found.

Robin
  • 305
  • 2
  • 13

1 Answers1

0

You need to make two changes to your server.xml

  1. Add a new Host element with the name attribute pointing to the DNS name of your computer/server. If server has no name registered with DNS, you may use the local name resolver (in unices it's the /etc/hosts file, there is a similar file in Windows) to add a host name of your choice and map it to an ip assigned to the server's network interface.

  2. You then need to change the defaultHost attribute, on the Engine element named catalina, to point to this host you just added