aspose file tools*
The moose likes Servlets and the fly likes Intermittent problem blank html page being displayed 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 » Java » Servlets
Bookmark "Intermittent problem blank html page being displayed" Watch "Intermittent problem blank html page being displayed" New topic
Author

Intermittent problem blank html page being displayed

Daniel Ralphs
Greenhorn

Joined: Dec 21, 2008
Posts: 4
Hi, im quite new to the java language and i have been doing an assignment to make a simple game that allows a user to enter a word on a jsp page and sends the users input to the servlet and match it against a random word generated.

Anyway i have come across this bug where when a word is submitted by the user the response generated by the servlet is just a blank html page with no source code or anything. The strange thing is it does not happen all the time.

Any help you can give me regarding this bug would be greatly appreaciated as this bug is starting to slowly drive me insane .


[ December 21, 2008: Message edited by: Daniel Ralphs ]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by Daniel Ralphs:
Hi, im quite new to the java language and iv been doing an assignment to make a simple game that allows a user to enter a word on a jsp page and sends the users input to the servlet and match it against a random word generated.
What is it, 'iv' ? Please write words full out. You're here at an international forum where proper English is expected. I for one am not native English, so I -as many others- wouldn't understand quickly the meaning of childish/sms/chat talk.

Anyway iv come across this bug where when a word is submitted by the user the response generated by the servlet is just a blank html page with no source code or anything. The wierd thing is it doesnt happen all the time.
Don't you see anything in the appserver's logs either?


Any help you can give me regarding this bug would be greatly appreaciated as this bug is starting to slowly drive me insane .


Only thing what I can tell about this is that you shouldn't be mingling presentation logic with controller/business logic. Use JSP for presentation. This might also clear up the cause of the problem or even solve it.
[ December 21, 2008: Message edited by: Bauke Scholtz ]
Daniel Ralphs
Greenhorn

Joined: Dec 21, 2008
Posts: 4
I have edited my previous post now and i have changed it sorry for the confusion.

Don't you see anything in the appserver's logs either?


I am running the servlet through the netbeans ide using the tomcat server, in the log i get this message.

SEVERE: Servlet.service() for servlet counter threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 8
at java.lang.String.charAt(String.java:687)
at counter.counter.letterMatchCount(counter.java:135)
at counter.counter.processRequest(counter.java:45)
at counter.counter.doPost(counter.java:88)

I did not see that error message before, i was only looking in the main run log.

[ December 21, 2008: Message edited by: Daniel Ralphs ]
[ December 21, 2008: Message edited by: Daniel Ralphs ]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by Daniel Ralphs:
I am running the servlet through the netbeans ide using the tomcat server, in the log i get this message.

SEVERE: Servlet.service() for servlet counter threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 8
at java.lang.String.charAt(String.java:687)
at counter.counter.letterMatchCount(counter.java:135)
at counter.counter.processRequest(counter.java:45)
at counter.counter.doPost(counter.java:88)

I did not see that error message before, i was only looking in the main run log.

Great, now you have found the cause of the problem. Fix it accordingly.

About the blank page; you already wrote to the response inside the servlet (instead of using JSP), thus the web container can't change it anymore to give you the standard error page with the details about the exception like you got in the logs. If you was using JSP for presentation, you would have noticed it much earlier.
[ December 21, 2008: Message edited by: Bauke Scholtz ]
Daniel Ralphs
Greenhorn

Joined: Dec 21, 2008
Posts: 4
Thanks for the help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Whenever you get a blank page like that, chances are close to 99.9999999999% that there's been an exception thrown.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Ralphs
Greenhorn

Joined: Dec 21, 2008
Posts: 4
Problem now fixed thanks for the help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Intermittent problem blank html page being displayed