Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Set a session variable from a properties file

Posted on 2006-11-29
Medium Priority
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 700 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 28

Expert Comment

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

Assisted Solution

rrz earned 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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