新手,关于servlet的问题

我在前台提交表单到servlet,调用的doPost方法
在doPost方法里面创建了一些类的对象
当前台调用servlet的时候出错,但是也有不出错的时候,但是连续两次提交一定出错

具体是这样的
index.jsp:
<FORM name=frmTrText action="<%=path %>/servlet/Analyzer" method="post" ;>
--------------------------------------------------
Analyzer.java:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String output="";
String input=request.getParameter("trtext").toString();
StringReader stream = new StringReader(input);
Compiler a = new Compiler(stream);
output=a.start();
RecordBean record = new RecordBean();
record.setContent(input);
record.setResult(output);
record.setId(0);
record.setTime(null);
HttpSession s = request.getSession();
s.setAttribute("record", record);

response.sendRedirect(request.getContextPath()+"/index.jsp");
}
--------------------------------------------------
HTTP Status 500 - :

type Exception report

message

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

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.ExceptionInInitializerError
servlet.Analyzer.doPost(Analyzer.java:54){代码是这一行:"Compiler a = new Compiler(stream);"}
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
java.io.StringReader.<init>(Unknown Source)
JavaBean.Gcompiler.<clinit>(Gcompiler.java:5)
servlet.Analyzer.doPost(Analyzer.java:54)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
------------------------------------------------

Compiler类是JAVA CC生成一个类,构造方法接受一个StringReader,里面有很多方法,比较复杂,用于语法分析的。
RecordBean是一个实体类,很简单。

觉得好像是去不能重复的定义那个Compiler的对象a
这样有涉及到servlet里面对象的生命周期的问题
想法是可不可以申明一个全局的对象,然后在servlet里只使用不声明

本人只是初学者,不知道怎么解决问题,故求助,谢谢……

建议你加个断点,看走到哪一步报的错!