aspose file tools*
The moose likes Tomcat and the fly likes Tomcat serving Blank Page - shows on Refresh - why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat serving Blank Page - shows on Refresh - why?" Watch "Tomcat serving Blank Page - shows on Refresh - why?" New topic
Author

Tomcat serving Blank Page - shows on Refresh - why?

Bridget Carlson
Greenhorn

Joined: Oct 08, 2009
Posts: 15
Hello all,

I recently signed up for a web host provider. My website pages are Java Server Pages.
My server runs with the following applications and versions.
Apache web server 2.2
Tomcat 5.5.27
Java 1.5.0.19 (SE 5)
Mysql 5.1.38
Mod_jk 1.2.28

I uploaded my site and began testing. I also configured what was necessary, per the instructional guides provided by the hosting company.

On occasion I have been getting a blank page, when accessing either the homepage or another page, at first attempt. If I request a page, and it returns blank, all I have to do is hit the Refresh key and everything loads. Each page after that loads as well.

What could the problem be? Your help is greatly appreciated. This problem concerns me very much.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

Have you asked the host?

In any case, what does a View Source show when you get the blank page? Nothing at all?

Anything in the Tomcat logs.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bridget Carlson
Greenhorn

Joined: Oct 08, 2009
Posts: 15
Yes, I contacted the host about this. They told me that they are not experiencing this problem. They have tried accessing the site on various operating systems in various locations. The site loads every time. They are unable to replicate the problem.

The View Source on one page showed a certain amount of the JavaScript code, but stopped at one point.

The logs, yes I looked at the Tomcat log, and most notable was the NullPointerException. It was issued on an object who's value is set via an interaction between the JSP page and a Servlet. The servlet interacts with a database, retrieves a value from a table, and sets the value into the session.

So the code causing the NullPointer in the jsp page looks like this ;


The Servlet is retrieving a value from the database and setting that value into the session.


But a refresh loads the page and the site operates as it should. What could be the problem?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

Did you not think that was relevant information to include in your initial post?

Yes, an NPE will stop everything in its tracks and you'll only get a partial response. You need to track down the cause of the NPE and fix it.
Bridget Carlson
Greenhorn

Joined: Oct 08, 2009
Posts: 15
Bear Bibeault wrote:Yes, an NPE will stop everything in its tracks and you'll only get a partial response. You need to track down the cause of the NPE and fix it.


How do you explain the NPE not occurring on the Refresh?

If it was the code, the page would not load at all....agree?

So ruling out the code, what other areas can I look into?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
I would suggest making sure that the response output stream gets flushed/closed under all conditions. Many of my "iee the screen is blank" problems have been resolved by this.

Bill
(if all your pages are JSP, why bother with Apache web server, it just slows things down and is a pain to configure.)
Bridget Carlson
Greenhorn

Joined: Oct 08, 2009
Posts: 15
I created my website and tested things locally, on my pc, with tomcat server (localhost).
Everything worked fine. Would it not also fail locally if there was a problem with the code???

On the host provider, I'm using mod_jk. Which is the Apache Tomcat connector. Are there any specific settings or attributes that I should be looking into, that might help solve my problem?

Bridget Carlson
Greenhorn

Joined: Oct 08, 2009
Posts: 15
Update On Problem

After adding some out.print's to my servlet, I got more precise information as to why this problem has been occurring.

The following error was revealed -

The last packet successfully received from the server was63030 milliseconds ago.
The last packet sent successfully to the server was 63030 milliseconds ago, which is longer
than the server configured value of 'wait_timeout'. You should consider either expiring and/or
testing connection validity before use in your application, increasing the server configured values
for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid
this problem.
java.net.SocketException: Broken pipe

What fixed this issue in my case, was adding the following to the my.cnf file on my server, under [mysqld], and then having the mysql server restarted.

[mysqld]
interactive_timeout=80000

In addition, I added the following to the server.xml file under the Resource parameters for connecting to the database -
testOnBorrow=true
validationQuery=select 1

I'm so very pleased with the results, and wanted to post this update. Perhaps someone else having the same problem I did will find this information to be of help

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tomcat serving Blank Page - shows on Refresh - why?