MollyPages.org
"You were wrong case. To live here is to live." |
Pages /
Database /
Forms /
Servlet /
Javadocs
/
License & Download /
Tutorials /
Cookbook
/
Contact & Hire
|
Internally, a servlet RequestDispatcher is used to include the file. If a included file name is absolute (begins with a '/'), then it is relative to the servlet webapp, otherwiser it is relative to the current page.
Any molly declarations and code are ignored in the included file. (see include-file and include-decl for alternatives).
You can however, send additional parameters to the included page even when using dynamic includes.
[include "file.mp?greeting=hello"]The included file (file.mp in this example) will return null for request.getParameter("greeting"). The fix for this is:
[[ req.setAttribute("greeting", "hello"); ]] [include "file.mp"]Now, in the included file (file.mp), one can say request.getAttribute("greeting") and this will return hello.
[include filename]Quotes around the filename are optional.
The name of the included file can contain expressions and hence be generated dynamically. For example:
[[ int i = 3; ]] [include 'foo[=i].html' ]will include a file called
foo3.html
in the page.