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

/jsp:include SCWCD Exam Study Kit

 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings.

I would appreciate guidance regarding review question # 6 from Chapter 13 - Reusable Web Components in the book SCWCD Exam Study Kit by Hanumant Deshmukh and Jignesh Malavia.

What I do not understand is how the red and green param values appear in the colors array.

The question is as follows:

File 1: this.jsp

html body pre
jsp:include page="that.jsp"
jsp aram name="color" value="red" /
jsp aram name="color" value="green" /
/jsp:include
/pre /body /html

File 2: that.jsp

%
String colors[] = request.getParameterValues("color");
for (int i=0; i<colors.length; i++)
{
out.print(colors[i] + " ");
}
%

What will be the output of accessing the this.jsp file via the following URL?

http:/localhost:8080/chapter13/this.jsp?color=blue

The answer is: red green blue

Explanation

The parameters passed via the <jsp aram> tag to an included component tag take precedence over the parameters already present in the request object of the including component. Also, the order of values passed via the <jsp aram> tag is the same as the order in which the tags appear. Thus, the correct answer is c. The output will be red green blue.

Thank you in advance for your assistance.

Jerry Bustamente

ps. pardon the absence of left and right carrots in the syntax. When I tried to submit this question I received,

"FYI We cannot post your topic because the subject contains < or >. Subjects may not contain this combination of those characters. Use your back button to try again."
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that param tag is nested inside include tag. Also the attribute color is an array type so we can assign as many values as we want to it.

Therefore the values inside param are parameters to included page.
Thanks
Imad
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad,

Thank you so much for your considerate reply. I understand now.

Sincerely,

Jerry Bustamente
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic