This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Global Variable in JSP pages  RSS feed

 
Feybian Yip
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to ask is there any method which can keep a variable among different jsp pages which are virtual included within a page.
Or store in session is the only method to do so?
Fey
 
Jason Kilgrow
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't think of another place to put it than in the session. I suppose you could specify application scope but I've rarely used this. Quite frankly, I'm not sure I know how to use application scope.
Hmmm...I suppose you could have a static class with a static member variable. But then, all of your applications would have scope to that variable.
Originally posted by Feybian Yip:
Hi,
I want to ask is there any method which can keep a variable among different jsp pages which are virtual included within a page.
Or store in session is the only method to do so?
Fey

 
Sam Dalton
Author
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the variables in the servletcontext. This will then be available from ALL servlets/jsps/tags in your web application
Rgds
Sam
 
Cameron Park
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either put it in ServletContext in a scriplet or in a bean with Application scope. A good example that is often put in the ServletContext is a site accessed counter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!