Solved

Property Bean Not displaying on JSP Page

Posted on 2013-11-15
2
1,112 Views
Last Modified: 2013-11-21
Hi,

I've created a Bean in my servlet-context.xml file.  It references a properties file and I would like to call and display those properties on my JSP page.  I'm using Spring 3.1 MVC.

Here's my bean from Spring's servlet-context.xml:

    <beans:bean id="propertyConfigurer"   
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <beans:property name="location" value="/WEB-INF/app.properties" />
    </beans:bean> 

Open in new window


Here are the contents of my app.properties file in WEB-INF:

app.env=development
app.VersionNo=v9.0
app.VersionBuild=.1

Open in new window


Here are the attempts to access the values in the jsp:

<title>${VersionNo} ${app.VersionNo}</title>

Open in new window


Any help would be greatly appreciated.

blue
0
Comment
Question by:blue44
2 Comments
 
LVL 20

Accepted Solution

by:
Amitkumar Panchal earned 500 total points
ID: 39654121
If you are using spring tags then try the following.

1. load spring tags in jsp
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

2. use spring taf to render the property
<title>${VersionNo} <spring:message code="app.VersionNo" /></title>
0
 

Author Closing Comment

by:blue44
ID: 39668199
It helped but I wish there was a way to do this without using the Spring tags.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now