• Post Reply Bookmark Topic Watch Topic
  • New Topic

forward issue

 
Amit Meshram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My servlet code:


My JSP code




Output:
I design and manufacture before making a forward... (On Browser)
Inside the servlet!!!. (On Console)
Make a request dispatcher..... (On Console)

I have explicitly flushed the data before forward, so i got what i am expecting. But where did the forward go then??? Because I also expected
"Exit the servlet gracefully.." to be printed on console, which it didnt do???
So for me it means that servlet's doGet method didnt complete, and has gone to some infinite loop... where??? dats d question???
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Meshram:
My servlet code:



I have explicitly flushed the data before forward, so i got what i am expecting. But where did the forward go then??? Because I also expected
"Exit the servlet gracefully.." to be printed on console, which it didnt do???
So for me it means that servlet's doGet method didnt complete, and has gone to some infinite loop... where??? dats d question???


System.out.println("Exit the servlet gracefully...!!!"); never execute because you forward your control to /checkbox/forwardIsHere.jsp
 
Krishna Srinivasan
Ranch Hand
Posts: 1879
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you forward to another page the control will never comeback to the origin page.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Krishna Srinivasan:
when you forward to another page the control will never comeback to the origin page.


Not true.
Control will be returned to the calling method (just like any other method call in Java).
This can result in an IllegalStateException if you attempt to write to the output buffer after it's already been committed.
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ben wrote your flush() is the cause of problem. You can't forward if response is already committed, so your JSP just rose an exception. You can try replace forward() by include().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!