I need to define a String Object sT in a declaration tag as in: <%! String st = ""> Then I want to assign this string a value within some scriptlet tags such as: <% st = "filename.html %> finally I want to include that string within an include tag as in: <%@ include file=st %> But I keep getting messages saying that st isn't defined...this is because the include tag is called before I define and assign a value to st. How can I enforce the scriptlet and declarative tags to be called before the include tag? Do I have to include another JSP?
include directive is pre-compiled so everything is already pre-set. Your code looks right to me except in the scriplet <% st = "filename.html %> Maybe it will work if it's corrected <% st = "filename.html" %> That case, if the include directive is placed after the above scriplet, it will be <%@ include file = "filename.html"%>
Cameron Park
Ranch Hand
Joined: Apr 06, 2001
Posts: 371
posted
0
include directive is pre-compiled so everything is already pre-set. Your code looks right to me except in the scriplet <% st = "filename.html %> Maybe it will work if it's corrected <% st = "filename.html" %> That case, if the include directive is placed after the above scriplet, it will be <%@ include file = "filename.html"%> Hope this helps.
I'm pretty sure this isn't possible with the import statement, since it doesn't support a runtime expression value for the file attribute. ------------------ Adam Chace Author of :JSP Tag Libraries Chalk Creek Software
Adam Chace<BR>Author of :<A HREF="http://www.amazon.com/exec/obidos/ASIN/193011009X/electricporkchop/102-2552103-3190518" TARGET=_blank rel="nofollow">JSP Tag Libraries</A><BR><A HREF="http://www.chalkcreek.com" TARGET=_blank rel="nofollow">Chalk Creek Software</A>
There are two ways to include another page in a JSP. Using the directive as in : < %@ include file="foo.jsp" %> A directive cannot take a runtime expression. One advantage this has is the include happens at compile time and has the best overall performance. The second is to use the jsp tag include. This is included at run time. I ran a quick test on Tomcat 3.2.1 and it does allow a runtime expression < % String s = "foo.jsp"; %> < jsp:include page="<%= s %>" flush="true"/>