Trying to add init parameter names to a list in init(ServletConfig) method.
public void init(ServletConfig sc){
try {
super.init(sc);
Enumeration<String> e= sc.getInitParameterNames();
while(e.hasMoreElements()){
list.add(e.nextElement());
}
} catch (ServletException e1) {
e1.printStackTrace();
}
}
I am getting a NullPointerException when I use this list because e.hasMoreElement() returns false.
I am pretty sure that I have added the init parameters correctly in the web.xml file.
What is going wrong? Please advice.
I think you have not
intializedthelistobject. Thelistobject is null.Change the code list this: