• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

trick question : page directive + forward

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Ernesto...
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, u�re right.
The only one difference is about the "carriage return".

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic