Jsp Exception Handling

Exception Handling

In Jsp exception is handled as we are provided with two attributes of page directive:



On Page from where we can get runtime exception, we can specify the errorPage as shown below:

  <%@ page errorPage="error.jsp" %>  

And on error.jsp page we need to add below page directive:

  <%@ page isErrorPage="true" %>  

And then on this page we can display cutomized message or exception details.

  <h3>Some Exception occured!</h3>  
  Exception is: <%= exception %>  

Other then using this jsp provided way of handling exceptions we can use try catch block in scriptlets.


  catch(Exception e){

( function() { if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; }; var unit = {"calltype":"async[2]","publisher":"manishh03","width":300,"height":250,"sid":"Chitika Default"}; var placement_id = window.CHITIKA.units.length; window.CHITIKA.units.push(unit); document.write('
'); }());