Could anyone provides me some solution?
I encountered "HTTP 500 internal server error" while testing a jsp that forwards to an error page whenever user inputs a wrong data type on a web form to sum 2 inputted numbers. The application server version I am using is JBoss 4.0.5.GA application server.
My Calculate3_html.jsp file is:
<HTML>
<HEAD><TITLE>Calculator</TITLE></HEAD>
<BODY>
<%@ include file="Calculate3Header.html" %>
<P>Enter 2 nos. and click the Calculate button.
<p>
<FORM METHOD=GET ACTION=Calculate3.jsp>
<INPUT TYPE=TEXT NAME=Value1><BR>
<INPUT TYPE=TEXT NAME=Value2><BR>
<INPUT TYPE=SUBMIT VALUE=Calculate>
</FORM>
</BODY></HTML>
My
Calculate3.jsp file is:
<%@ page language="java" pageEncoding="UTF-8" errorPage="Calculate3Error.jsp" %>
<%!
// No try/catch for NumberFormatException
private double toDouble(String value) {
return Double.parseDouble(value);
}
%>
<%
double value1 = toDouble(request.getParameter("Value1"));
double value2 = toDouble(request.getParameter("Value2"));
double sum = value1 + value2;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<%@ include file="Calculate3Header.html" %>
The sum of <%= value1 %> and <%= value2 %> is <%= sum %>
</body>
</html>
My
Calculate3Header.html file is:
<H1><I>A Simple Calculator (Exercise 3)</I></H1>
My
Calculate3Error.jsp file is:
<%@ page language="java" pageEncoding="UTF-8" isErrorPage="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<%@ include file="Calculate3Header.html" %>
Calculate3Error.jsp reported the following error:
<I><%= exception %></I>
<br>
<a href="Calculate3_html.jsp">Click here to try again</a>
</body>
</html>
Thank you.
Calson