
July 24th, 2001, 08:14 PM
|
|
Junior Member
|
|
Join Date: Jul 2001
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
howto? using include file for global variables in JSP?
Seems to not work in JSP but maybe I'm missing something obvious?
In many other languages (php, perl, asp, C, whatever), I often make an "include" file which contains things like variables /constants for things like fonts, colors, etc. And even some global user-defined functions for special formatting, etc.
How is this done in JSP? From what I can tell, this doesn't work.
say.. inc.jsp contains:
String g_font_face="Verdana";
and then any file (say "foo.jsp") should be able to:
out.print (g_font_face);
as long as inc.jsp is "included" in "foo.jsp".
But the following "inclusions" don't allow me to use g_font_face as a valid variable. (foo.jsp complains that g_font_face is undeclared).
RequestDispatcher rd = request.getRequestDispatcher("inc.jsp");
rd.include(request, response);
=doesn't let me use any variables defined in inc.jsp
pageContext.include("inc.jsp");
doesn't either....
Don't tell me JSP doesn't allow for global user-defined variables. That would really suck. But I could imagine some Object-Oriented purists saying this was a "good thing".
|