The JSP include action goes something like: <jsp:include page="test.jsp"/> while the JSP include directive goes something like: <%@include file="test.jsp"%> Whats the significance of the fact that the JSP include action is processed at request time while the JSP include directive at translation time? TIA - Chris
High. The significance is high. Do you know C? If so, are you familiar with the #include directive? The include directive in JSPs directs the compiler that's going to compile a JSP, to REPLACE every include directive that it finds with the text contents of the included file. Just like #include in C. And that's all there is to the include directive. Nothing new there if you know C. Now to where the (include) action is! For this you must understand that JSPs are converted literally into source code for servlets first by the JSP engine and then compiled to bytecode just like any other servlet that you may have written by hand. The file included with the includeaction is converted to a servlet and compiled into bytecode (if it hadn't been already) and its output (whatever it is) is inserted at the point of inclusion in the enclosing servlet-that-corresponds-to-the-original JSP. In other words, it's like chaining different servlets together: The first servlet (actually the compiled mother JSP) starts executing, then the servlet engine executes the one that has been included by the include action, then it goes back to the original one and so on. I know this has not been the best explanation, but "that's what the ship brought for now..." PS: There are consequences (differences) as to the scope of variables with each type of includes.
Tony Alicea Senior Java Web Application Developer, SCPJ2, SCWCD
Joined: May 25, 2001
Cool, thanks a lot. Can you elaborate on the consequences (differences) as to the scope of variables with each type of includes? TIA Chris