Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

AppConstants in JSP?

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to refer to a value from the AppConstants file into a jsp? Anyone have a example of this?
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi matt,
can you explain in a bit more details what you are trying to do. I am just wondering....before giving an answer that does not cover your question.
regards
 
Matt Hoffman
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.. I have a value in the database that I need to check. The value is a 7 so I want to display certain text on the screen when the value it is a 7. I don't want to hard code the number in the application.

Here is what I have now..

<c:choose>
<c:when test="${ test.test1.name == '7'}">
<bean:message key='message.test'/>
</c:when>
<c therwise>
 
</c therwise>
</c:choose>
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
write a custom tag that does the job for you. Take a look at:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
chapter 15. Then this tag goes to the database and check the value. Then this value can also print of the right text that could also be variable from the database.
regards, and good luck
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several problems in doing so.

First, we need to build up our own taglib, which cannot make good use of existing JSTL and EL functions.

Also, as JSP is already in the presentation, should we make a DB connection at the presentation, instead of getting the value from Controller and pass to the view?

Third, I guess he just wanna replace the value "7" by a Java Constant, and that value, I suppose, is coded in a Java class. I am not sure whether EL can accept scriptlet, have you tried to use <%=xxx.seven%> to replace it? where xxx is the Java class that contain the constant. Otherwise, you might consider to put the constant into request scope, so that EL can access it by ${test_value == seven}.

Nick
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic