• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Help: valid declarations in a JSP page

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I encounter a question on j2eecertificate and I don't understand the answer.
Which of the following are valid declarations in a JSP page? [Check all correct answers]


1) <jsp:getProperty Name="id" Property="streetName"/>
2) <jsp:getProperty property="streetName" name="id"></jsp:getProperty>
3) <jsp:getProperty name="id" class="com.baboon.scwcd.Address" property="streetName"/>
4) <jsp:getProperty name="id" property="streetName"/>
5) <jsp:getProperty property="streetName" name="id"/>

Answer is 4) and 5).
But why not 2)? 2) and 5) are the same, right?
Kelvin
[ January 15, 2004: Message edited by: Kelvin Hung ]
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think because the <jsp:getproperty> should be closed in the same tag like this <jsp:getProperty/> and not in a closing tag like this </jsp:getProperty> because the getProperty does not take any content between its opening and closing and instead it uses only attributes to define it s behavior.
Please correct me if I am wrong.
 
Kelvin Hung
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think a closing tag has to be in this format </tagName>
<jsp:getProperty> should take empty body, and I think 2) is equal to empty body, right?
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
same question answered here -
https://coderanch.com/t/167233/java-Web-Component-SCWCD/certification/Jsp-Tag
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jayadev Pulaparty,

https://coderanch.com/t/167233/java-Web-Component-SCWCD/certification/Jsp-Tag


JSP tag syntax does not permit for opening and closing tags with jsp:getProperty. You must provide a single tag that is 'self-closing.' Option 2 is therefore invalid syntax.


I have no idea where the JSP specification forbids using getProperty as <jsp:getProperty...></jsp:getProperty>. The only contraint I can find is that "getProperty" must has an "empty body". Per xml syntax, the "empty body" for an element can be presented as "<someElement/>", AND "<someElement></someElement>" as well.
I have tested both syntax for "getProperty" under Tomcat 5.0.16, and both work well.
 
Kelvin Hung
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup Hover, I would vote the answer of the question is wrong.
reply
    Bookmark Topic Watch Topic
  • New Topic