title: how to split string in JSP
body: <p>I have a String in JSP which I need to split by special char <code>,</code>. But I'm unable to split it: when trying the code below I'm getting the following error:</p>
  
  <pre><code>    org.apache.jasper.JasperException: java.lang.NullPointerException
       org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:556)
                                   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
       org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
       javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
       org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  
  
      root cause 
  
      java.lang.NullPointerException
      org.apache.jsp.test1jsp_jsp._jspService(test1jsp_jsp.java:115)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>My Code:</p>
  
  <pre><code>&lt;%@page import="sun.security.util.Length"%&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                                                                               
    http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;%
      String arr1 = request.getParameter("arr");
      String[] a = arr1.split(",");
      for(int x=0; x&lt;a.length; x++)
          out.println(a[x]+"&lt;br&gt;");
      %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How do I fix this?</p>