• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

String literal constants - opinion sought.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the practices we follow at my workplace is to create a Constants class to store string literals that can be referred to throughout the application.

However, this approach encourages the use of scriptlet code in jsps, instead
of JSTL. For example.

If I have a request parameter foo that is being used all over the app. In the non EL world I would use..

<input type="hidden" name="<%= Constants.PARAM_FOO %>" >

But in JSTL I use

<input type="hidden" name="${param.foo}" >

Notice how the word "foo" is hardcoded in the page now.

We are also encouraging the use of EL and JSTL, but find this in direct
conflict with our old practice of keeping constants in one place.

Is there a way to keep the constants in one place and still use EL?
 
Marshal
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I addressed an approach to this in an article in the August 2005 JavaRanch Journal.

An article I am currently writing for the December issue of the Journal also will address this topic.
 
Jason Pepper
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That would work.
 
There's a city wid manhunt for this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic