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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With