I am writing a JSP program with a java class and trying to build an array of objects, but getting NullPointerException. Kindly sort out my problem.

My java class is `MChart.java` is here below:

```
package myPackages;

public class MChart 
{
    private  String[] stateId = new String [100];  
    private  String[] rule      = new String[100];
    private  String[] dotPosition   = new String[100];
    private  String[] backPointer   = new String [100];
    private  String[] operation = new String[100];

    public void intialize (String s, String r, String dp, String bp, String o)
    {

        stateId[0]  =   s;
        rule[0]     =   r;
        dotPosition[0]  =   dp;
        backPointer[0]  =   bp;
        operation[0]    =   o;

    }
    public String getStateID(int i)
    {
        return stateId[i];
    }
    public String getRule(int i)
    {
        return rule[i];
    }
    public String getDotPosition(int i)
    {
        return dotPosition[i];
    }
    public String getBackPointer(int i)
    {
        return backPointer[i];
    }
    public String getOperation(int i)
    {
        return operation[i];
    }
}

```

and now my jsp file is as below:

```
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="myPackages.MChart"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<title>QASKU URDU PARSER</title>
<!-- scripting code is deleted -->
</head>
<body>
<form name="myform" method="get"  >

<div align="center" onKeyPress="return checkSubmit(event)">
<h4>QASKU URDU PARSER</h4><br>
<h5>Type sentence using Urdu/Arabic script only and then press the 'Parse' button below</h5><br>
<textarea cols="100" rows="5" style="text-align: right" name="mytextarea" id="message" >Type here</textarea>
<script type="text/javascript"> blurfocus("message"); </script>
<br><br>
<input type="submit" value="Parse" >
</div>

</form>

<%
try
{
    if ( request.getParameter("mytextarea") == null)
    {
        out.println("<p align='center'>No Any Input Yet</p>");
    }
    else
    {
        <!-- database entries are deleted -->

        // inputting sentence from user and splitting into an array of strings

        String sent = request.getParameter("mytextarea");
        String[] input = sent.split(" ");

        //initialize chart and root rule
        MChart[] chart = new MChart[input.length+1];
        // only beginning instance is initiated and the rest will be initiated on 
           runtime // This also the NULL pointer creating statement
           chart[0].intialize("0", "ROOT S", "0,0", "-1", "Seed");

        out.println("<p><table align=center border='1' bgcolor='green' width='75%'><col width='25'><col width='25'><col width='25'><col width='25'><col width='25'>");
        out.println("<tr><th align=left>STATEID</th><th align=left>RULE</th><th align=left>DOT-POSITON</th><th align=left>BACK-POINTER</th><th align=left>OPERATION</th></tr>");
        out.println("<tr><td align=left>"+chart[i].getStateID(i)+"</td>");
        out.println("<td align=left>"+chart[i].getRule(i)+"</td>");
        out.println("<td align=left>"+chart[i].getDotPosition(i)+"</td>");
        out.println("<td align=left>"+chart[i].getBackPointer(i)+"</td>");
        out.println("<td align=left>"+chart[i].getOperation(i)+"</td></tr>");
        out.println("</table></p>");

}
catch (Throwable any) 
{
    out.println("<p align=center>Java ERROR: "+any+"</p>");
    any.printStackTrace();
}
%>
</body>
</html>

```