开发者

JSP duplicate if included multiple time

开发者 https://www.devze.com 2023-04-09 03:00 出处:网络
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

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.


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

  1. http://javapapers.com/jsp/difference-between-jsp-include-directive-and-jsp-include-action/

  2. http://www.geekinterview.com/question_details/701

  3. http://www.daniweb.com/web-development/jsp/threads/105695

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号