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 Define Constants 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 "Define Constants" Watch "Define Constants" New topic
Author

Define Constants

gurcharan singh
Greenhorn

Joined: Dec 21, 2002
Posts: 16
I want to define my custom constants, not finding any link on how to do it - Anyone has any insight to it.

Also, how can I upload custom settings for different installations, say, Dev and Production, with each having it's own constants/settings.

Thanks!

Gurcharan
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Custom constants for what? If you want to allow user value changes keep them in a database.

I'm not sure how this is related to Struts yet.
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 133
Gurcharan, This can be done if you are using Ant for building your application. Define custom values as place holders and in ant script replace these values with real one depends upon environment. Ant has its own task to replace it.

-Sunil
gurcharan singh
Greenhorn

Joined: Dec 21, 2002
Posts: 16
David Newton wrote:Custom constants for what? If you want to allow user value changes keep them in a database.

I'm not sure how this is related to Struts yet.


This is my first app with Struts. In past I'd worked with different framework in other programming languages, like, DJango where we can define different settings files and based on our installation (Dev, Prod) we used to refer the specific settings. So I was exploring do Struts provide this kind of freedom.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

In general this kind of thing isn't really related to Struts itself, and would be handled via JNDI, property files, Spring, or compilation/execution properties.

If you have an example of the kinds of constants you're thinking about we might be able to help better, or direct you to a more appropriate forum.
gurcharan singh
Greenhorn

Joined: Dec 21, 2002
Posts: 16
David Newton wrote:In general this kind of thing isn't really related to Struts itself, and would be handled via JNDI, property files, Spring, or compilation/execution properties.

If you have an example of the kinds of constants you're thinking about we might be able to help better, or direct you to a more appropriate forum.


The settings can be - Whom to email in different mode, Don't send specific emails in dev mode, A specific set of validations need not to be performed if the installation is dev.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Custom Constant : the simple solution is Properties File[As David Suggested]
gurcharan singh
Greenhorn

Joined: Dec 21, 2002
Posts: 16
Thanks for the insight!!
 
 
subject: Define Constants
 
Similar Threads
finder methods in WSAD with Oracle Database
Problem with Custom Challenge Type
Avoding multiple ifs
Error in method signature
Define constants !