my dog learned polymorphism*
The moose likes Tomcat and the fly likes Global String object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Global String object?" Watch "Global String object?" New topic
Author

Global String object?

Ed Carrington
Ranch Hand

Joined: Oct 11, 2007
Posts: 77
In Tomcat 4.1.27 how can I create a String object that I can call in any of my Java classes?

For example I have a String object like this: String mymessage = "hello world";

Anyway I can put that in web.xml or some other file and call the mymessage variable in any Java class?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Without telling us what you intend for the string, what's wrong with good old:



?

This is, of course, not Tomcat or even web app specific.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ed Carrington
Ranch Hand

Joined: Oct 11, 2007
Posts: 77
Originally posted by Bear Bibeault:
Without telling us what you intend for the string, what's wrong with good old:



?

This is, of course, not Tomcat or even web app specific.


Thanks for your quick response.
Where do I put that so I can call it anywhere in my webapp (called ProjectOne) folder: System.out.println(GLOBAL_STRING);
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

This is just basic Java. You can put it in any class and reference it (since it is static) using the class name.

Note that many people would frown up globals such as this. You still haven't told us what you want to do with this string. Someone might have suggestions for better practices.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Global String object?