July 24th, 2001, 08:14 PM
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:
and then any file (say "foo.jsp") should be able to:
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");
=doesn't let me use any variables defined in inc.jsp
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".
July 25th, 2001, 05:03 AM
it can be done with this way
your .jsp files should begin with
and also for definition you can use <!% ... %> tags
July 26th, 2001, 04:27 PM
That was it! works great now.
July 26th, 2001, 05:18 PM
don't forget reading the sprcifications
sometimes it contains something interesting