Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9319985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:31:20+00:00 2026-06-19T03:31:20+00:00

I am creating a standard dynamic web project including a Servlet, a filter to

  • 0

I am creating a standard dynamic web project including a Servlet, a filter to filter the request and jsp pages.
I am taking the number of books from the welcome.jsp and depending on the count I am populating the input boxes on the add.jsp. I want to filter the data coming through the add.jsp. When I verify data through Regex, its showing me error. Also is my flow correct i.e. from the start FILTER –> CONTROLLER –> FILTER –> PAGE and so on???

Error:
java.lang.NumberFormatException: null

full trace is like:


HTTP Status 500 - java.lang.NumberFormatException: null

type Exception report

message java.lang.NumberFormatException: null

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NumberFormatException: null
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    com.filter.RequestFilter.doFilter(RequestFilter.java:107)

root cause

java.lang.NumberFormatException: null
    java.lang.Integer.parseInt(Unknown Source)
    java.lang.Integer.parseInt(Unknown Source)
    org.apache.jsp.WEB_002dINF.add_jsp._jspService(add_jsp.java:139)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    com.filter.RequestFilter.doFilter(RequestFilter.java:107)

The code where its showing is:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    // TODO Auto-generated method stub
    // place your code here
    boolean flag = true;
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    httpServletRequest.getServletPath();
    System.out.println(httpServletRequest.getServletPath());


    String address = InetAddress.getLocalHost().getHostAddress();
    System.out.println(address); 


    // For the first time (Welcome page) i will be 0 so that it will perform first if

    if(i == 0)
    {
        System.out.println(i);
        if(verify(address))
        {
            chain.doFilter(request, response);
            i++;
        }

        else
        {
            RequestDispatcher requestDispatcher = httpServletRequest.getServletContext().getRequestDispatcher("/WEB-INF/forbidden.jsp");
            requestDispatcher.forward(request, response);
            return;
        }

    }

    // For the second time (Controller) i will be 1 so that it will perform first if


    else if(i == 1)
    {
        System.out.println(i);
        i++;
        System.out.println("after ++"+i);
        chain.doFilter(request, response);
    }

    // For the second time (add page) i will be 2 so that it will perform first if


    else if(i == 2)
    {

        if(specialChara(httpServletRequest))
            {
                System.out.println(i);
                System.out.println("done");
                i++;
                chain.doFilter(request, response);
            }

            else
            {
                System.out.println(i);
                flag = false;
                System.out.println(""+httpServletRequest.toString()+ "\n"+httpResponse.toString());
                RequestDispatcher requestDispatcher = httpServletRequest.getServletContext().getRequestDispatcher("/WEB-INF/add.jsp");
                requestDispatcher.forward(request, response);

            }
    }

    // For the third time (Controller) i will be 2 so that it will perform first if

    else if(i == 3)
    {
        System.out.println(i);
        i++;
        chain.doFilter(request, response);
        i = 0;
    }

Its giving error on the line of forward() in the loop where i==2.
What might be the issue?

link of add.jsp is https://docs.google.com/document/d/1fOzymYvlLXS577DrSrznRoeBnI7_hMmuqzFoK02xKoU/edit?usp=sharing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:31:22+00:00Added an answer on June 19, 2026 at 3:31 am

    From the stack trace it seems that the problem is not with your java class, but rather your JSP. My guess is in the line

    int no = Integer.parseInt(request.getParameter("no"));
    

    no seems to be null.Also you are better off using and other conditional tags rather than using scriptlets in your JSP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a standard MVC 3 project there is an EntityFramework.dll and .xml file
Is there a standard solution or some implementation for creating animations with color filter
I observed some unexpected behavior with TTLauncherView from Three20. After creating a standard view
I am creating a standard jQuery UI tab bar, nothing special except for the
I am creating a pretty standard business application in WPF. I need to use
The standard way of creating URLs in grails is: <a href=${createLink(controller:'news', action: 'show', params:
Is there a trick for creating a faster integer modulus than the standard %
When creating a <header> within a HTML document is there a standard way of
Is there an RFC, official standard, or template for creating a User Agent string?
Hi there i want to create a dynamic functionality like creating dynamic form in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.