Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set & get an application scope variable?

Status
Not open for further replies.

FreshmenProgrammer

Programmer
Jan 16, 2006
42
CA
Hello,

First I would like to say thanks in advance for the help!!

This is the error im getting.
SEVERE: null
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:209)

I'm not sure if im not setting the application scope variable right or im not getting it right because i'm always getting a null value. Please let me know the right way of getting and setting application scope variables. Thank you!!

Code:
EISDAO eis = new EISDAO();
eis.setDBHost(config.getInitParameter("dbhost"));
//etc etc..

// i set the application scope variable in an init like this
config.getServletContext().setAttribute("eisdao", eis);

//
public SISDAO getEISDAO() {

return (EISDAO)getServletContext().getAttribute("eisdao");

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top