aspose file tools
The moose likes JSP and the fly likes String literal constants - opinion sought. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "String literal constants - opinion sought." Watch "String literal constants - opinion sought." New topic
Author

String literal constants - opinion sought.

Jason Pepper
Greenhorn

Joined: Oct 15, 2005
Posts: 9
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56153
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Jason Pepper
Greenhorn

Joined: Oct 15, 2005
Posts: 9
Thanks. That would work.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String literal constants - opinion sought.
 
Similar Threads
c:if and c:choose
Array as queryString
Read JavaScript array values in Java class
Scriptlet to JSTL
Instantiate object without scriptlet