Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is .jspf file extension? How to compile it? [duplicate]

What are .jspf files in JSP? As I know the compiler will look for .jsp files to compile, then how are the .jspf files compiled?

like image 958
giri Avatar asked Jan 17 '10 12:01

giri


People also ask

What is. JSP file extension?

What is a JSP file? The JSP files are realized as the dynamic, data-driven pages for your Java web applications. The JSP means Java Server Pages; can be realized as an extension to Servlet because it enables more functionality than servlet such as expression language.

What is ajsp file?

A JSP file is a Java document used to dynamically generate a webpage using Jakarta Server Pages (JSP) functions. It is similar to an . ASP or . PHP file, except it contains Java code instead of ActiveX or PHP. Web servers parse JSP files and use them to generate HTML, which is sent to a user's web browser.

What is the difference between JSP and JSPF?

The file with . jspf extension is called JSP fragment; a static file included in another JSP file. The JSPF files are not compiled on their own, however, they are compiled along side the page in which they included. Its syntax is similar to the Java Server Pages (JSP) code.


2 Answers

As others have noted, .jspf files are JSP fragments. They're designed to be statically included in another JSP file, not compiled on their own:

<%@include file="/WEB-INF/jspf/example.jspf" %> 

You'll note that this example comes from the /WEB-INF/jspf directory. This means that it is not accessible outside of the web application; there's no way to construct a URL that can retrieve it. If you put them in the same directory as "normal" JSP files, you can construct such a URL; Tomcat, for example will retrieve the page as a text document. A front-end web-server, however, can block these URLS.

I like JSPF files as a first step in refactoring large JSP pages. Since they're statically included, you can extract a small chunk of the file without making provision for scriptets or variables, leading to pages that are somewhat more maintainable (and I want to stress, it's a first step; dynamic includes and taglibs are usually a better long-term solution). When refactoring, I believe in keeping the fragments close to their parent files; this is when having a web-server to block URLs becomes useful.

like image 54
kdgregory Avatar answered Oct 09 '22 11:10

kdgregory


JSP Fragments can be compared to server side includes. These fragments are not compiled on their own, however there are compiled along side the page in which its included. If I've to display different pages base on a user preference, i will opt for jspf.

like image 41
kodepet Avatar answered Oct 09 '22 13:10

kodepet