package com.lesi.lcms3.core;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
public class NewClass extends HttpServlet {
private ServletContext sc;
public String aVer()
{
LiveInfo li = (LiveInfo) sc.getAttribute("live");
return li.getTest();
}
@Override
public void init(ServletConfig config) throws ServletException
{
super.init(config);
sc = config.getServletContext();
}
}
why im getting a null pointer on the sc.getAttribute line?
On Jan 31, 2011, at 7:36 AM, Konstantin Kolinko wrote:
> 2011/1/31 alexis <[email protected]>:
>> actually im already using a class extending servletcontextlistener, this
>> class is the responsible to start all other threads on processing. Some
>> threads stores results on a DB, some threads should store results in an
>> object to be accesed by a servlet and presented via web.
>>
>> If i use the a) approach and i use it as Listener, how can i access this
>> class from other threads/classes on my webapp?
>
> ServletContext#setAttribute(String,Object)
> ServletContext#getAttribute(String)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]