When the interface method also throws an exception, you must remove the catch blocks without
try { //.... } catch(IOException e){ throw new ServletException("kiasku " + e.getMessage(), e); }
And how your exception handling should work.
EDIT:
Did you apply the ServletContextListener interface methods correctly? They are not in your sample code. But they must be in class.
As far as I can see, interfae methods do not throw any exceptions. When you really want to BREAK notify the listener, you need to throw a RuntimeException.
EDIT2:
I would change too
if(!str.equals("aasditya")){ throw new ServletException(); }
to
if(!"aasditya".equals(str)){ throw new ServletException(); }
source share