Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trick question : page directive + forward

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

"Consider the source for the following two JSP pages, a.jsp and b.jsp. What i steh outcome of requesting each in turn? You can assume tha c.jsp is available in the same web app directory as a and b pages."

a.jsp


b.jsp



Options:
A - neither JSP pages translate.
B - a.jsp translates ; b.jsp does not.
C - b.jsp translates ; a.jsp does not.
D - Both pages translate.
E - Neither JPP page runs successfully.
F - a.jsp runs successfully; b.jsp does not
G - b.jsp runs successfully; a.jsp does not
H - Both pages run successfully.

Tip: oh god , sincerelly, i wouldn�t remember myself from this issue at this point, pay atention.

(is that even correct?)

tks.
 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading tje JSP Spec 2.0 page 111

It says about <jsp:forward>

"...If the page output was unbuffered and anything has been written to it, an attempt to forward the request will result in an IllegalStateException..."

so as long as you do not have any output before the <jsp:forward>
the jps should compile and run OK.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hum..almost there Ernesto

there still is another trick issue here..

(tip: a.jsp page reagrding its content)

 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the only difference would it be the break-line in "a.jsp"
the container may interpret the breakline as template text and
send it to the outputstream in that case the <jsp:forward> becomes invalid because the stream is not buffered so it flushed. so "a.jsp" should throw and illegalstate exception. while "b.jsp" should be OK.
 
Vivek Kinra
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ernesto...
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, u�re right.
The only one difference is about the "carriage return".

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic