I want to throw a ServletContext exception from a method in a class which implements ServletContextLister
.
Here is my implementation which is failing:
public class Initializer implements ServletContextListener {
private void checkEncryptedFile() throws ServletException {
FileReader fr;
try {
fr = new FileReader("TestFile");
BufferedReader br = new BufferedReader(fr);
String str = br.readLine();
if(!str.equals("aasditya")){
throw new ServletException();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
catch(ServletException se){
throw new ServletException("kiasku " + se.getMessage(), se);
}
}
}
Can anyone suggest any alternate methods. Please guide me on this. Thanks