This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm going to assume you are refering to the difference between the <jsp:include> standard action and the include directive.
<jsp:include page="somePage.jsp" /> -- dynamic The above standard action includes a page at runtime (a RequestDispatcher is obtained and the include() method is invoked). This is a bit slower than the directive because it includes the reponse of the included file at runtime.
<%@ include file="somePage.jsp" %> -- static The include directive inserts the contents of the included file (somePage.jsp) at translation time (in other words, when the container turns your jsp into a servlet). This is considerd the way apropriate when the included contents is not likely to change.
Regards, Marzo. [ January 15, 2006: Message edited by: Marzo Kaahn ]
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA
Live life to an interface, not an implementation!
Joined: Dec 22, 2005
Hi Marzo, Thanks for ur reply. I have one more related doubt. Assume i have a.jsp. In this, I include b.jsp.
And there are some common parameters in both the jsp. In this case I think that, at translation time, it would cause some problem because there would be duplicated variables in the servlet. Is this the case for both static and dynamic include or are there any exceptions ?
If the include directive (the static way) is used, you can use a variable that is not declared in the included page but is declared in the page that includes it, because there is no problem, given that once translated, the included contents will have access the the declared variable.
If the jsp standard action is used, the variable must be declared in the included page, given that it is the response (result) which gets added, so it should have it's own variables (unless of course you pass a parameter to the included file).
Best regards, Marzo. [ January 16, 2006: Message edited by: Marzo Kaahn ]