Directives

Directives are messages to the container that are processed at compilation time. The important directives are:

<%@ page ... %>

<%@ include file = "foo.html" %>

The important page attributes are:

<%@ page import = "..." %>

<%@ page extends = "..." %>

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

<%@ page isErroPage = "..." %>

Handling Errors

error.jsp

<%@ page isErrorPage = "true" %>
<%@ page import = "java.io.*" %>
<html>
<head> <title> My Error Page </title> </head>
<body>
An error has occurred <br />
<%= exception.getMessage() %> <br />
<% exception.printStackTrace(new PrintWriter(out)); %>
</body>
</html>

thrower.jsp

<%@ page errorPage = "error.jsp" %>
<%!
   void foo1() throws Exception { foo2(); }
   void foo2() throws Exception { foo3(); }
   void foo3() throws Exception { if (true) throw new Exception("foo3 blew it!"); }
%>
<html>
<head><title> Throw Demo </title> </head>
<body>

I am going to throw an exception now:
<% foo1(); %>
</body>
</html>