Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Given a jsp page called index.jsp with the content

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
String greeting="morning";%>${greeting}
<jsp:forward page="menu.jsp" />
<h1>Hello</h1>
And a menu.jsp file available to index.jsp containing


<%
greeting = greeting +" morning";
out.print(greeting);
%>What will happen when you attempt to compile and run index.jsp?



Choose one answer. A. Compilation and output of morning good morning
B. Compilation and output of good morning
C. Compilation and output of good null
D. Compilation but runtime error


I am confused about the answer..The answer should be a. But this a answer is not correct.
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello amandeep

I think the answer should D, because only at runtime the menu.jsp will be executed and it finds the variable greeting not declared and hence produces runtime error.

Srividhya
 
Ramesh Ponnada
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
menu.jsp has a compilation error, as variable greeting is not defined in its scope.

you'll get a 500 (Internal Server Error) which is caused by this compilation error.

I am not totally convinced with answer D, but its the closet one so will go with it.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramesh Ponnada:
you'll get a 500 (Internal Server Error) which is caused by this compilation error.


exactly.it will happen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic