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
Java 184.108.40.206 (SE 5)
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.
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 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?
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.
(if all your pages are JSP, why bother with Apache web server, it just slows things down and is a pain to configure.)
Joined: Oct 08, 2009
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?
Joined: Oct 08, 2009
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
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.
In addition, I added the following to the server.xml file under the Resource parameters for connecting to the database -
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