0

i get an error "org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 18" i think my exception code is wrong. i don't know how to return an empty string when the user doesn't enter any number and clicks "continue". any suggestions

<%@ page import="java.io.*"%><%@
page import="java.util.*"%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<%
    String sum = (String) session.getAttribute("sum");

            sum = "5";
            session.setAttribute("sum",sum);

    int isum = Integer.parseInt(sum);
    try {
    isum=Integer.parseInt(request.getParameter("number"));
    } catch (NumberFormatException nfe) {out.print(" ")}      
    if(request.getParameter("number")!=null && Integer.parseInt(request.getParameter("number"))==isum)
    {
     if(request.getParameter("submit") != null){
            out.print("Hello");}
    }
  %>

  <body>
    <title>MAIN</title>
    <form action="index.jsp" method="post">
    Enter 5 = <input type="text" name="number">
    <input type="submit" value="continue" name="submit">
    </form>


 </body>
 </html>

Edited by peter_budo: Moving to JSP section

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by thines01
0

Does isnum actually hold a valid value?
Does the problem happen before 18 and is just exposed there?

0

isum holds whatever the user enters, but when the user doesn't enter anything i get an error

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.