This is the statement I have in my
JSP <%SampleClass sample= new SampleClass(); %>
Here is part of my SampleClass.
HttpServletRequest request = null;
String path = request.getContextPath();
public void createFile() throws IOException{
File f;
f=new File(path+"WEB-INF/test.txt");
if(!f.exists()){
f.createNewFile();
}
}
my jsp is giving me this error
java.lang.NullPointerException
com.SampleClass .<init>(SampleClass.java:32)
can someone tell me what the issue is and how to fix it? I do know that I am not suppose to have request = null but what can I do to initialize it?