I have used below lines in my web.xml so that if GenericException occurs in the applicaiton, genericException.jsp can be invoked.
<error-page>
<exception-type>com.example.GenericException</exception-type>
<location>/WEB-INF/jsp/genericException.jsp</location>
</error-page>
I want to display the exception.getMessage() on my screen only if it is numeric. When I was trying to print it on the screen using ${exception.getMessage()}, it didn't work
Instead, I had to use <%=exception.getMessage() %> to print the same on screen.
I want to print the same only if it is a number (error code basically).
My problem is that I am not able to check if this is a numeric or not. Can somebody tell me how will be the logic in jsp for the same.
Till now, I have put the IF conditions on ${exception.getMessage()} kind of variables using c:if test =
But not able to put IF condition on <%=exception.getMessage() %>
<%@page import="com.example.GenericException"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isErrorPage="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head><title>Error Message</title></head>
<body>
<form action="" method="post" >
<center>
<br><br>
<table width="90%" height="100px"
style=" -moz-border-radius: 8px; -webkit-border-radius: 8px;border-radius: 8px;border: 2px solid #467aa7;">
<tr>
<td style="color:#467aa7;">
<%
GenericException e = (GenericException) exception;
int code = e.getErrorCode();
String message = e.getErrorMessage();
if (code != 0) {
message = code + " : " + message;
}
%>
<label><%=message %></label>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.