Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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 ]
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic