Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP Performance using jsp:include

Tags:

I am beginning to break apart a large JSP file into a some smaller JSP pages so I can reuse this across other areas of the site.

I can take the approach of leaving as a large Monolithic JSP file that takes params and adjusts it's behavior accordingly. The other approach I can take is breaking it apart so that it's called via jsp:include.

What is the performance concern in creating additional request calls that are dispatched from within the server? Is it better performance wise to keep it as one jsp page?

like image 693
Shaun Avatar asked Sep 25 '09 19:09

Shaun


People also ask

HOW include JSP file in another JSP?

To include JSP in another JSP file, we will use <jsp:include /> tag. It has a attribute page which contains name of the JSP file.

Which attributes used with JSP include?

2. Attributes of JSP include action. URL of the included page which is interpreted as relative to the current JSP page. The included resource can be static like HTML or dynamic like JSP and Servlet.

How can I make my JSP page load faster?

You can load all ip addresses from db into an ArrayList and also load all ips which are alive into another ArrayList and compare these two arrays. This should be much faster.

What is the difference between <%@ include directive include and JSP include?

The <%@include file="abc. jsp"%> directive acts like C "#include" , pulling in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text). The <jsp:include page="abc.


1 Answers

The jsp:include is a runtime directive unlike the <%@ include ... %> directive which happens to be a compile time directive (translation time, actually). A compile time include directive is relatively harmless since JSPs are usually precompiled for production, or in the worst case compiled for every deployment of the application. For this reason, it is preferable to use the compile time directive for static files, since the files are not bound to change at runtime.

The runtime include directive on the other head, if misused, can result in some performance hit, especially for static files being included. This is primarily because the JSP container would have to then fetch the contents of the static file and include them in the response. Hence, reserve the usage of the runtime directive for the really useful scenarios where another servlet or jsp's response is to be included in the response, and not merely to make the code look good.

like image 92
Vineet Reynolds Avatar answered Sep 21 '22 10:09

Vineet Reynolds