This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes How to share variables in Struts tiles? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to share variables in Struts tiles?" Watch "How to share variables in Struts tiles?" New topic
Author

How to share variables in Struts tiles?

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
In a jsp class called Init.jsp I define some variables that has to be used by all the jsp pages. An example is:

java.util.Locale ressources = ( java.util.Locale ) init.get("ressources");

At the moment I got an error because the other jsp pages don�t know the variables defined in the init.

cannot resolve symbol ressources

How can I solve the problem?

Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Set the variables to a scope (request, session, application).


A good workman is known by his tools.
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
Will you give an example, please?

Her is some piece of my Init.jsp file:


Is that a good way to initialize the parameters, which all the other jsp pages (tiles) are going to use?
[ June 19, 2005: Message edited by: Jeppe Fjord ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to share variables in Struts tiles?
 
Similar Threads
Tiles Question - howto solve variety body ?
How tiles are resolved in a JSP page
Tiles & Validator
Problem in resolving an issue in Tiles
Tiles winding me up.