Set a session variable from a properties file

Posted on 2006-11-29
Last Modified: 2010-04-01

Hi all,

I it possible to set a session variable from some kind of properties file?

Ive been trying this:

( "amt, <bean:messagekey="sub.amt" /> );

But I get this error:

Missing term. session.setAttribute( "amt, <bean:messagekey="sub.amt" /> );

Thanks for any help
Question by:SuAeE
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 29

Accepted Solution

bloodredsun earned 175 total points
ID: 18035805
Yes it is but not like that. You can't mix custom tags with scriptlet java code. You need to do it all in the scriptlet code.

    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream(""));//make sure the name of the file is correct
    } catch (IOException e) {
       //deal with the exception
    //add the value to the session object
    session.setAttribute( "amt", properties.getProperty("sub.amt") );


Author Comment

ID: 18035819

ah I see, ill try that, thanks

Author Comment

ID: 18037128

Im having trouble accessing the file

Im using:
  properties.load(new FileInputStream(request.getContextPath()+"//config//");

But im getting the error: "Cannot find the file specified"

I'll increase the points, thanks
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 27

Expert Comment

ID: 18037319
you can try using  
properties.load(new FileInputStream(request.getContextPath()+"/config/");
LVL 27

Assisted Solution

rrz earned 100 total points
ID: 18038446
Sorry, that last one needs to find it on the classpath( in the classes folder for example).  

Author Comment

ID: 18038709

thanks, ;)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
A look at what happened in the Verizon cloud breach.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

624 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