SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 24th, 2001, 08:14 PM
idoit idoit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 0 idoit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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".

Reply With Quote
  #2  
Old July 25th, 2001, 05:03 AM
Alexandr Alexandr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Belarus
Posts: 30 Alexandr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
  #3  
Old July 26th, 2001, 04:27 PM
idoit idoit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 0 idoit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Alexandr,
That was it! works great now.
Thanks,
John

Reply With Quote
  #4  
Old July 26th, 2001, 05:18 PM
Alexandr Alexandr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Belarus
Posts: 30 Alexandr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
don't forget reading the sprcifications
sometimes it contains something interesting

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > howto? using include file for global variables in JSP?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway