You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jorge Ruben Macias Lopez <jm...@protel.net.mx> on 2002/11/21 17:45:31 UTC

Problem with application scope data

Hi, I've been reading through the lists archive and still can't find the way
to make this work. I'm doing the following:

- Created a subclass from ActionServlet, with the following code:

public class IDCVActionServlet extends ActionServlet{
    
    public void init() throws ServletException {
        
        try{
            super.init();
        }
        catch(ServletException e){
            throw(e);
        }
        initIDCV();
    }
    
    protected void initIDCV(){
        getServletContext().setAttribute("demo", new ValueBean("Mensaje
Demo"));
    }
}

the class ValueBean is the following:

public class ValueBean{
    protected String data;
    
    public ValueBean(String data){
        this.data = data;
    }
    
    public String getData(){
        return(this.data);
    }
    
    public void setData(String data){
        this.data = data;
    }
}

I modified web.xml to load my custom class instead of the standard
ActionServlet, then I try to print demo.data in a jsp, like this:
<bean:write scope="application" name="demo" property="data"/>

but I get a nullPointerException, can someone point me to the right way of
doing this?  

Regards, 
Jorge Macias

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>