| Author |
JSP and JSPF
|
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 241
|
|
Whats the difference between JSP and JSPF, I understand JSPF is JSP Fragment. WHat exactly is meant by that ? How can I craete a JSP fragment ? What is the difference between them from coding point of view ? What do I need to include or exclude from JSp in order to create a JSPF ?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
By convention a .jspf file is a fragment included into another page with the include directive, but not the include action.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 241
|
|
|
Is there any diference in coding of JSP and JSPF ? If I want to give JSPF extension to a JSP page, will that work ? or do I need to code JSP page in a certain way in order to call it JSPF ? If there is no difference in coding, then why need JSPF ? We can just create JSP page and include it in another JSP page with include action (oe whatever legal way). What difference does it make , if you are using JSP or JSPF if there is no difference in coding or of other kind ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
nirjari patel wrote:Is there any diference in coding of JSP and JSPF ?
A jspf doesn't need to be a complete and sytnax-complete JSP, as it is statically included in a JSP (that does need to be complete).
If I want to give JSPF extension to a JSP page, will that work ?
Of course not. Why would you do such a thing?
do I need to code JSP page in a certain way in order to call it JSPF ?
The JSP simply uses the include directive to include the fragment.
We can just create JSP page and include it in another JSP page with include action (oe whatever legal way).
Yes, you can do that. But in the case of the include action, the included JSP must be syntax-complete.
|
 |
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 241
|
|
Thanks. Things are lot clearer now. I tried to google for this info, but nowhere any useful info is provided about JSPF. Any idea which website or book explains these things in detail and with sample code ?
Can you please provide a sample code of JSPF in here ?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
My simplest example:
|
 |
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 241
|
|
|
Not this simple please. Something incomplete in code from which I can figure out some rules. Please also mention a book or an article to read tgrough for more details.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
There's no book or article that I am aware of. That's because it's just a simple concept which you apparently missed from my example: a fragment file can contain anything that can be statically included in a JSP.
|
 |
nirjari patel
Ranch Hand
Joined: Apr 23, 2009
Posts: 241
|
|
Can I view a JSPF page in the web link , the way I can view a JSP page ? Or do I need to call a JSPF pafe within a JSP page and then only I can view it ?
By that I mean , can a JSPF be used independently on its own ?
I am working on Interwoven CMS in which we have two programs. One is outputting JSP page and other code is outputting JSPF page. Now when I click on JSP page, I can seethe final output, how it will look in webpage. Nut when I click om JSPF, I get an error "Oops! This link appears to be broken.".
So now I am thinking, is it allowed to use JSPF without embedding or calling it in JSP page ?
Thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Already covered. A JSP fragment can only be included into a JSP page.
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1005
|
|
It should be noted that the JSPF extension is more of a convention/best practice rather than officially specified.
Kind of like struts uses the ".do" extension, and we use 'i' for a loop variable.
The JSPF extension is an indication to the programmer that
"This file is a fragment of a JSP and will only be used via <%@ include %> in other JSPs"
There is nothing mandatory about this. You don't have to use the JSPF extension. You can include any file you like with the <%@ include %> directive.
It is merely a defacto standard that has emerged of "this is the way we do things around here".
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26216
|
|
|
Also consider if you should use a tag file instead. Since you can have a tag file implemented in JSP language, the include feels more natural. I've been using tag files for reusable code and haven't used a jspf since tag files allowed HTML/JSP (rather than having to be implemented in Java.)
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: JSP and JSPF
|
|
|