|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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". |
|
#2
|
|||
|
|||
|
hi. idoit
it can be done with this way your .jsp files should begin with <%@include file="inc.jsp"%> and also for definition you can use <!% ... %> tags |
|
#3
|
|||
|
|||
|
Alexandr,
That was it! works great now. Thanks, John |
|
#4
|
|||
|
|||
|
don't forget reading the sprcifications
sometimes it contains something interesting |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > howto? using include file for global variables in JSP? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|