Java.Servlet.What implicit objects are not available in a regular JSP page?

👉 The exception object is NOT available in a regular JSP page.

ObjectAvailable in regular JSP?Notes
request✅ YesAlways
response✅ YesAlways
session✅ YesAlways
application✅ YesAlways
out✅ YesAlways
config✅ YesAlways
pageContext✅ YesAlways
page✅ YesAlways
exception❌ NoOnly in error pages

🔥 Why is exception not available?

  • exception is used to capture a thrown exception when an error occurs.
  • It’s only created if the JSP page is explicitly marked as an error page using this directive:
<%@ page isErrorPage="true" %>

Without that setting:

  • The JSP does not know to expect an exception object.
  • If you try to use exception on a normal page, you’ll get a compilation error.

📚 Example:

1. Normal JSP page (home.jsp)

<html>
<body>
    Hello, World!
    <%-- No exception object here --%>
</body>
</html>

exception ❌ not available.

2. Error JSP page (error.jsp)

<%@ page isErrorPage="true" %>
<html>
<body>
    <h2>Error occurred!</h2>
    <p><%= exception.getMessage() %></p> 
</body>
</html>

exception ✅ available because isErrorPage=true.

🎯 Final Quick Summary:

ObjectAvailabilityNotes
All other implicit objects (request, response, session, etc.)✅ Always available in JSP
exception❌ Only available if the page is an error page (isErrorPage="true")
This entry was posted in Без рубрики. Bookmark the permalink.