Reputation: 4365
let say i have this global.jsp that include a database configuration and connection.
I know this is not the best way to do this, and I didn't allow to use anything else then a pure jsp. The problem is when is this file is included in more than once then i got re-declaration error. Is there any way to do this ? something like IFDEF on C perhaps.
Thanks.
Upvotes: 4
Views: 4200
Reputation: 30855
Check the jsp include concept here is the simple detail and difference of the include directive tag and include action tag
should use the include directive (<%@ include file="relativeURL" %>
):
if the file includes static text
if the file is rarely changed (the JSP engine may not recompile the JSP if this type of included file is modified)
if you have a common code snippet that you can reuse across multiple pages (e.g. headers and footers)
should use the <jsp:include />
for content that changes at runtime
to select which content to render at runtime (because the page and src attributes can take runtime expressions)
for files that change often
here are the links
Upvotes: 1