aspose file tools*
The moose likes JSP and the fly likes JSP or JSPF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP or JSPF" Watch "JSP or JSPF" New topic
Author

JSP or JSPF

Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Hi
I am having a JSP, and in my JSP i have to include some part of code, actually i have around 20 JSPs and in all the 20 JSPs i have to include some common code, so what i have done is i have made another JSP and included it in the main JSP, Here am not sure whether to the extension of the included JSP should be .jsp or .jspf.
Can any one please explain what is the difference between the two extensions and what i have to use in the above mentioned scenario.
The knowledge i have is if it is .jsp means server creates _Jsp.java and a corresponding class file for that, please let me know which is better to use and why!


SCJP 1.5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Generally, .jspf is used for JSP fragments that are included via the static include directive. JSP files included via the standard include action are processed as their own page and are given the type .jsp.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Thanks Bear.
Can you please explain when do we use standard include action (<jsp:include page=""/>) and when do we use the static include directive (<%@ include file=""%>)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Generally, you use the directive to include fragments, which may or may not be complete and parsable JSP files. For example, a prelude that contains taglib directives that you are going to use on all pages (see below for caveat). These includes happen before translation.

The standard action is used to include complete and separately parsable JSP pages at run-time.

That said, I rarely use either anymore. I use a prelude defined in the deployment descriptor to prefix all pages with common directives, and custom actions or tag files to share common code.
Amol Ghotankar
Greenhorn

Joined: Feb 09, 2013
Posts: 1
HI Bear,

Thanks for the explanation. I still have a couple of doubts, could you please answer them

1. How does it matter if I include tag lib on every page vs in a common jspf vs in web.xml - does it help to improve speed or just manage large projects & change?


2. What are standards practices to include tag lib and common code like headers & footers other than using sitemap or any such plugin?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

1) I would venture to say that any performance difference are irrelevant and that you should do whatever provides the most clarity in the context of your project.

2) I know of no "standard practices". There are many layout libraries to choose from. (Some even do everything on the client side).
 
jQuery in Action, 2nd edition
 
subject: JSP or JSPF