jsp 页面这样,然后服务器抛出空指针错误
 <%@ page contentType = "text/html;charset= gbb2312" %>
<%@ page language = "java" pageEncoding = "gb2312" %>
<%@ page import = "java.util.*" %>
<%@  page import = "java.sql.*"%>


<html>
<head> 你好,本页面提供到库登记</head>
<body>
<form name = "form"  action = "" method = "post">
<p>入库单编号<input type = "text" name = "id" value = "2">
<br><p>对应教材库的编号<input type = "text" name = "textbookId" value= "1" >
<br><p>入库数量<input type = "text" name ="amount" value = "9">
<br><p>入库日期<inpt type = "text" name = "arrivalDate" value ="12-23-2">
<br><div align = "right"><input type = "submit" name ="submit" value = "录入" />
</div></form>
</body>
</html>
<%!int id,
        textbookId,
        amount,
         rs;
%>
<%  String  ids = request.getParameter("id");
    String textbookIds = request.getParameter("textbokId");
    String amounts  = request.getParameter("amount");
    String arrivalDate = request.getParameter("arrivalDate");
    // StringBuffer str =new StringBuffer();

    //下面进行数据类型装换
    if(ids != null)
    id = Integer.parseInt(ids);
    if(textbookIds  != null)
    textbookId = Integer.parseInt(textbookIds);
    if(null != amounts)
    amount = Integer.parseInt(amounts);



    //进行数据库的验证

    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
    }catch(Exception e){System.out.println(e);}
    try{
    String url = "jdbc:sqlserver://localhost:1433;DatabaseName=Dian";
    Connection connection = DriverManager.getConnection(url,"chen","chen");
    Statement stmt = connection.createStatement();

    String sql = "insert into arrival_book values("+id+","+textbookId+","+amount+",'"+arrivalDate+"');";



    if(id != 0)
     rs = stmt.executeUpdate(sql);


    if(0 != rs)
 {
   // New location to be redirected
   String site = new String("addsuccess.jsp");
   response.setStatus(response.SC_MOVED_PERMANENTLY);//实现页面重定向
   response.setHeader("location", site); 
    }
    else
    {
    response.sendRedirect("add1.jsp");
//  str.append("添加失败");
    }
    }catch(Exception e){
    System.out.println("2222222");
    }

%>然后下面服务器

严重: Error processing request
java.lang.NullPointerException
at org.apache.catalina.connector.OutputBuffer.realWriteChars(OutputBuffer.java:457)
at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:393)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:275)
at org.apache.catalina.connector.Response.finishResponse(Response.java:453)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:578)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)

## ## 求助????

3个回答

页面这样,然后服务器抛出空指针错误

ruanjianchenming
Mintสดใส 困惑 我觉得很诡异
接近 6 年之前 回复

错误输出只有这些吗?

ruanjianchenming
Mintสดใส 这里是全部的输出
接近 6 年之前 回复

为啥要把java代码写在jsp页面,这是很不程序员的一种方式。

ruanjianchenming
Mintสดใส 写的系统比较简单,然后没有考虑太多 就写成这样了
接近 6 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐