This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher working, but ultimately sends an empty HTML page to client

 
Joseph Morgan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a really interesting situation under very normal circumstances, or so I thought.

My dev environment is Apache HTTP 2.2 -> Tomcat 6, Java 6

I have an HTML form posting to a servlet. The servlet receives the request, does some validation, adds some attributes to the request, and forwards to a JSP. The JSP runs in its entirety as evidenced through several System.out's littered throughout the page. The servlet stops processing as it should, as evidenced by the lack of the existence of a the result of a System.out in the servlet.

The really strange thing is, though, is that the client is left with a valid, but blank HTML page. I have no idea what is generating the blank page, but it nonetheless is what is returned to the client.

This may be more than what you want to see, but here is the code. Here is the servlet.


Any ideas are appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You showed a lot of code, but none of it is helpful. Where's the forward? All you show is a call to a proprietary routine that could be doing anything. Where's the JSP?

What do you mean by "valid but blank"?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please do not post the same question more than once. I've closed the other post.
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't see output from code which ought to produce output, that usually means that said code was not executed. I think in the example you displayed that could be because the line before it threw an exception.
 
D. Ogranos
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you see the System.out message "person map failed, forwarding back" then the servlet should forward to your jsp as the next step. So, (if you haven't done so already), check your logs if there are any exceptions for not finding the jsp, or if there are exceptions when it tries to execute. You could also add a System.out at the top of your jsp so you know it actually starts executing:

 
Joseph Morgan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies for the combined reply. I couldn't figure out how to reply to each individually.

Bear: The forward is there and clearly explained within the all caps comments in the code I posted. The code for the proprietary routine is displayed as well. Here it is again for reference:



The comments show up green to me in the original post. I thought it would be obvious the way I noted that and hoped it would reduce the need for anyone to read all of the code. I suspect if I can get it to flow properly past the noted point of code, the other places the forward occurs will work as well.

I did not post the message twice. However, I did make an edit to the original after posting and submitted that change. Maybe that's why the post displayed twice??

A blank but valid HTML means I'm getting:



And that HTML isn't being delivered by any code I have deployed to Tomcat nor Apache. So I suspect there is some kind of default routing it is hitting or page it delivers, but have no clue since the logs are empty of anything except what I explicitly output to them.

Paul: No exceptions are being thrown unless they can be thrown with no evidence of them in any logs anywhere. Actually, as stated in the orignal post, the forward is working just fine. I see all my System.out's in the Tomcat logs, both from the servlet and from the JSP. I do not see the:



in the logs, and I wouldn't expect to.

D. Ogranos: I littered my JSP with the exact kind of code you suggested. As stated in the original post, the JSP is running all the way through (there is a System.out after the last line of it). In fact, even the attributes are being passed in the request! The JSP completes just fine, and then it goes off to the blank HTML page shown above... which BTW, exists no where in my Tomcat app or Apache pages.

There are no exceptions showing up in the logs, and no errors showing up in the logs on either the Tomcat or Apache side. I can hit the JSP page directly through the browser and it works fine, so there are no issues with the JSP page. It has to be something about the forwarding that either I'm screwing up (though it seems simple enough). I also see the request to the servlet in the Apache access logs, and it returns a clean, 200!

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said a blank page - did you view source or use one of the many tools available to see the exact response content?

Just because the browser shows a blank page doesn't mean there is nothing returned, a partial page might display as blank.

Bill

Personally I am rather fond of the Firebug plugin for Firefox for study of requests and responses.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comments are not helpful. We need to see real code. Otherwise we have no way of knowing what's really executing.
 
Joseph Morgan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:You said a blank page - did you view source or use one of the many tools available to see the exact response content?


I'm glad you said that. I just viewed source. I used both HttpFox in FireFox, and then CURL, and both show absolutely nothing coming back. Also, FireFox's view source showed nothing, but IE's was showing the generated HTML. Therefore, the wonderful IE must be generating the HTML source I see when it gets nothing back. This make me feel just a tiny bit better, as at least I know some rogue blank HTML page isn't sitting in my server somewhere. I had combed my configs to be sure I had not accidentally (or boneheadedly) suppressed 4xx and 5xx messages.

So, the mystery still remains...here is the Apache log entry showing the hit to the servlet:



The only thing in the error.log of apache is the missing "favIcon.ico" entry.... And nothing except my System.out's from both the servlet and the JSP in tomcat logs (localhost, stdout, stderr). Nothing in mod_jk, and no errors anywhere.


 
Joseph Morgan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Comments are not helpful. We need to see real code. Otherwise we have no way of knowing what's really executing.


I'm losing you, man! I posted the entire servlet code, and the code from the superclass that couldn't immediately be seen, so all the the code related to the problem is there. Though I did show that in comments within the code, looking back, the only thing I could have done to make it more clear was to point out to pay attention to the comments that are all caps.

 
Joseph Morgan
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved.

Thanks for all replies.

Embarrisingly enough, I had incorrectly spelled "error.jsp" within my JSP and, thought the JSP was getting an error, it was trying to route to "eror.jsp"...

Go ahead Bear... I'm ready to hear it! You deserve to tell me!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can either accept the well-meaning advice that will help get you better and faster answers, or ignore it. The choice is yours.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the wonderful IE must be generating the HTML source


Ah yessssss the ever so helpful IE, which is why I prefer to debug with FireFox.

When you have to use IE - unset the "Show friendly HTTP error messages" option under Internet Options -> Advanced.

This will at least get you a chance of seeing the original error.

Bill
(I hate to think of the developer hours wasted by those friendly error messages)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic