P
pradeepsarathy
Hi all,
In the below code i am instantiating the request and session object at
the class level.But i am getting Null Pointer Exception while
instantiating.
Is it possible to instantiate a request object at class level.
I am doing so because,I want the request and session object to be
accessible in different methods of the same class.
Also all these methods(eg.method1()),will be called from SAX event
handler method(EndDocument() and character(char[] , int, int)),both of
which does not have provisions for passing the request obejct(or do
they?).
Please help me out.
Thanks in advance
-pradeep
import javax.servlet.http.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Session
public class xmlPocCmd extends AbstractCmd{
String onlyNumericElement = "";
String onlyAlphabetElement = "";
public static final String ONLYNUMERIC = "OnlyNumeric";
public static final String ONLYALPHABET = "OnlyAlphabet";
String[] errorArray = new String[2];
HttpServletRequest request; // Returns Null Pointer Exception
HttpSession session = request.getSession(false);
public String execute(HttpServletRequest req, HttpServletResponse res)
throws CmdException {
start(req);
return "xmlMarshallContainerPoc.jsp";
}
public method1(){
//Will accesss the request the session objects to set values;
}
}
In the below code i am instantiating the request and session object at
the class level.But i am getting Null Pointer Exception while
instantiating.
Is it possible to instantiate a request object at class level.
I am doing so because,I want the request and session object to be
accessible in different methods of the same class.
Also all these methods(eg.method1()),will be called from SAX event
handler method(EndDocument() and character(char[] , int, int)),both of
which does not have provisions for passing the request obejct(or do
they?).
Please help me out.
Thanks in advance
-pradeep
import javax.servlet.http.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Session
public class xmlPocCmd extends AbstractCmd{
String onlyNumericElement = "";
String onlyAlphabetElement = "";
public static final String ONLYNUMERIC = "OnlyNumeric";
public static final String ONLYALPHABET = "OnlyAlphabet";
String[] errorArray = new String[2];
HttpServletRequest request; // Returns Null Pointer Exception
HttpSession session = request.getSession(false);
public String execute(HttpServletRequest req, HttpServletResponse res)
throws CmdException {
start(req);
return "xmlMarshallContainerPoc.jsp";
}
public method1(){
//Will accesss the request the session objects to set values;
}
}