Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

/jsp:include SCWCD Exam Study Kit

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Muhammad,

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

Sincerely,

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