It's not a secret anymore!
The moose likes Tomcat and the fly likes JSP page is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply locked New topic

JSP page is "trashed" if Tomcat port is changed from 80.

Al Koch
Ranch Hand

Joined: Aug 24, 2011
Posts: 48


I have a servlet that uses three JSP pages. I am using Eclipse Indigo and running the Tomcat v5.5 server on localhost, port 80 and the app runs just fine. The app starts up with a login page (JSP page 1). The user credentials are authenticated and then JSP page 2 is displayed. The user clicks on a list item on this page to make a selection and JSP page 3 is "loaded" with the associated bean data and displayed. When running under port 80 there is no problem.

However, if I change the Tomcat port this breaks the app in a bizarre way. If I change Tomcat's port to, say, 25000, then JSP page 1 displays fine and we see JSP page 2. The user clicks to make a selection and again the associated bean data is used to "load" JSP page 3 and it is displayed. However, this time, the HTML [head] (can't use angle brackets in the post!) block that is delivered to the browser is the [head] block of JSP page ***2***. Further, the HTML [body] block that is delivered to the browser consists of the contents of the [body] block of JSP page ***2***, followed by the correct contents of the [body] block of JSP page 3! That is, the page that is "generated" out Tomcat is the [head] block from page 2 and a combination of the [body] block of page 2 and 3.

The [head] in JSP page 2 has four [script src=...] items that load four sets of JavaScript from the local server. One is a custom script, one is the Modernizr package and the last two are jQuery and jQuery Mobile. I have discovered that if I remove jQuery Mobile the problem goes away.

In summary, if I run Tomcat on port 80 I can include jQuery in JSP page 2 and there is no problem. If I change Tomcat's port to something other than 80, the inclusion of jQuery Mobile in JSP page 2 causes JSP page 3 to be trashed. At this point I don't think that jQuery Mobile itself could be the real problem - how could it cause JSP page 3 to include page 2? However, the Tomcat JSP processing facility is parsing, patching and generating these pages that are sent to the browser so it seems more likely that the problem lies there. But I have no clue as to why changing the Tomcat port # would affect JSP processing.

Is there something else I must change other than the port # on the Eclipse Tomcat v5.5 Server pane to ensure that JSP processing keeps working? Anyone who can explain what in the world is going on here really knows their stuff!!!

Thank you.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20273

Please UseOneThreadPerQuestion. Let's continue here.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: JSP page is "trashed" if Tomcat port is changed from 80.
jQuery in Action, 3rd edition