Null pointer Exception when retrieving value from ServletContext
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Saturday, December 1, 2001 01:32 AM

Hi I have a servlet that retrieves the value from The ServletContext. I used this code. try{ String file_path=null; if(getServletConfig().getServletContext().getAttribute("file_path") == null) { res.sendRedirect("/servlet/Warning"); } else { file_path=(String)getServletConfig().getServletContext().getAttribute("file_path"); } }catch(Exception e){System.out.println(e.toString()) } If the servletContext has the value for the key "file_path" it stores in a variable. else the the program redirects to another class(Warning.class)    More>>

Hi



I have a servlet that retrieves the value from The ServletContext.



I used this code.




try{


String file_path=null;


if(getServletConfig().getServletContext().getAttribute("file_path") == null)

{ res.sendRedirect("/servlet/Warning"); }

else

{ file_path=(String)getServletConfig().getServletContext().getAttribute("file_path"); }


}catch(Exception e){System.out.println(e.toString()) }




If the servletContext has the value for the key "file_path" it stores in a variable.

else the the program redirects to another class(Warning.class)


But I get the NullPointerException


Could you help me why this happens


Could you help me to solve the problem



thanks


sabu

   <<Less
About | Sitemap | Contact