• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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 ]
 
For my next trick, I'll need the help of a tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic