• 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

JSPFragment

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers, I was going thru the JSP fragment in page 502(HFS). But I am finding it difficult to grasp the concept. What exactly does JSP Fragment do. I mean...is it only for SimpleTagSupport.
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP fragments have .jspf extensions.
These are incomplete jsp pages.
you typically name a jsp with a .jspf ectension when ypu want to include that into another MAIN JSP (whose source code has a html and body tags). If you out the same tags for the included jsp alse, the resultabt jsp will have nested html and body tags which is incorrect.

Note that to enable .jspf stuff you need to add a declaration in web.xml
refer to HFSJ chapter 8 for this

Correct me if i m wrong
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The JSP fragment is JSP code without scripting codes. Actually JspFragment is Object which encapsulate JSP code into it that can be invoked as many times as needed.

The JSP fragments can be in the body of the SimpleTag handler. The fragment in the body is executed when the <jsp oBody> tag is encountered.




The invokation of tag in JSP file is

<%taglib prefix="test" tagdir="/WEB-INF/tags" %>
<test:tag1>
This body is treated as JSP fragment. It should not contain scripting. and the body-content should be "scriptless"
</test:tag1>



Also you can pass JSP frgment as attribute and the fragment can be executed by <jsp:invoke > standard tag.



The invokation of tag in JSP file is

<%taglib prefix="test" tagdir="/WEB-INF/tags" %>
<test:tag2>
<jsp:attribute name='frag1'>
This attribute value is treated as JSP fragment. It should not contain scripting.
</jsp:attribute>
</test:tag2>

You can also use the jsp fragment in Simple and custom tags in the attribute values. To do this you have to set the foollwing attribute options in tld file while defining the tag .



Assuming that the setter method in the tag implementation set the frag2 attribute in the tag correctly,
Then you can inoke this fragment attribute using the

frag2.invoke(null);

Hope this help
[ July 10, 2006: Message edited by: Narendra Dhande ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic