

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to handle error object in JSP using JSTL tags?
You can make use of JSTL tags to write an error page ShowError.jsp with better structure and more information −
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %> <%@page isErrorPage = "true" %> <html> <head> <title>Show Error Page</title> </head> <body> <h1>Opps...</h1> <table width = "100%" border = "1"> <tr valign = "top"> <td width = "40%"><b>Error:</b></td> <td>${pageContext.exception}</td> </tr> <tr valign = "top"> <td><b>URI:</b></td> <td>${pageContext.errorData.requestURI}</td> </tr> <tr valign = "top"> <td><b>Status code:</b></td> <td>${pageContext.errorData.statusCode}</td> </tr> <tr valign = "top"> <td><b>Stack trace:</b></td> <td> <c:forEach var = "trace" items = "${pageContext.exception.stackTrace}"> <p>${trace}</p> </c:forEach> </td> </tr> </table> </body> </html>
Access the main.jsp, the following will be generated −
Opps...
Error: | java.lang.RuntimeException: Error condition!!! |
URI: | /main.jsp |
Status code: | 500 |
Stack trace: | org.apache.jsp.main_jsp._jspService(main_jsp.java:65) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) |
- Related Questions & Answers
- What are JSTL Core tags in JSP?
- What are JSTL formatting tags in JSP?
- How to deploy JSTL .jar file in CodingGround JSP emulator?
- What the different types of JSTL tags are ?
- How to handle an exception in JSP?
- How to handle SSL certificate error using Selenium WebDriver?
- How to create a common error page using JSP?
- How to handle jQuery AJAX error?
- How to handle Assertion Error in Java?
- How to send an error code using JSP to browser?
- Is there any JSTL library to parse XML in a JSP?
- How many types of directive tags JSP supports?
- How to declare an object of a class using JSP declarations?
- What is JSTL?
- How to remove empty tags using BeautifulSoup in Python?
Advertisements