Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP and JSPF

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By convention a .jspf file is a fragment included into another page with the include directive, but not the include action.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My simplest example:
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Already covered. A JSP fragment can only be included into a JSP page.
 
Stefan Evans
Bartender
Posts: 1754
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34680
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic