Hi All

I have written JSP to read a text file(Text file and JSP are in same location) and display the data. when I am trying to run the JSP it is displaying "Error:Null".

here is my code

<% 

try{
java.net.URL url =config.getServletContext().getResource("/textfile.txt");BufferedReader buffreader =new BufferedReader(new InputStreamReader(url.openStream()));
String strLine;
while ((strLine = buffreader.readLine()) != null)  
{
	out.println(strLine);
}
	}catch (Exception e){
		System.err.println("Error: " + e.getMessage());
		}
%>

Thanks in Advance.

Try to print the stack trace in order to get a better understanding:

<% 

try{
java.net.URL url =config.getServletContext().getResource("/textfile.txt");BufferedReader buffreader =new BufferedReader(new InputStreamReader(url.openStream()));
String strLine;
while ((strLine = buffreader.readLine()) != null)  
{
	out.println(strLine);
}
	}catch (Exception e){
                e.printStackTrace(); // HERE
		System.err.println("Error: " + e.getMessage());
		}
%>

You probably get a NullPointerException somewhere