请问下这个错误是什么啊?我看不太懂这些错误信息,麻烦稍微教我一点怎么去看这些信息。我想把form表单提交的width和height转换为int类型,我记得昨天还能成功的.
今天就一直出现这个莫名其妙的问题。 顺便问下,我登录了csdn怎么老是会自动退出登录的?害我写好的帖子丢了好几次了type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Exception in JSP: /dongtaibiao.jsp:1916: <% String[] colorArray={"00","11","22","33","44","55","66","77","88","99","AA","BB","CC","DD","EE","FF"};%>
17: <% String w =request.getParameter("width");
18:    String h =request.getParameter("height");
19: int a =Integer.valueOf(w);
20: int b =Integer.valueOf(h);%>
21: 
22: 
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.valueOf(Unknown Source)
org.apache.jsp.dongtaibiao_jsp._jspService(dongtaibiao_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.
--------------------------------------------------------------------------------Apache Tomcat/5.5.28原代码是
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.util.*" %>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="dongtaibiao.jsp" method="post" name="form1">
<input name="width" type="text" value="3">
<input name="height" type="text" value="3">
<input name="" type="submit" value="GO"></form>
<% String[] colorArray={"00","11","22","33","44","55","66","77","88","99","AA","BB","CC","DD","EE","FF"};%>
<% String w =request.getParameter("width");
   String h =request.getParameter("height");
int a =Integer.valueOf(w);
int b =Integer.valueOf(h);%>
<%=w%>
</body>
</html>

解决方案 »

  1.   

    <% String w =request.getParameter("width"); 
      String h =request.getParameter("height"); 
    int a =Integer.valueOf(w); 
    int b =Integer.valueOf(h);%> 
    强制转换用int a =Integer.parseInt(w)
    int b =Integer.parseInt(h)
      

  2.   

    这个问题是Integer.valueOf(w);//这里边的w是null 
      

  3.   

    我开始也是这么想的,所以我给width加了个默认值3.
    但是还是出现同样的问题。当我删掉
    int a =Integer.valueOf(w); 
    int b =Integer.valueOf(h);时
    使用<%=w%>是可以正常显示出数据的
      

  4.   

    你这是在一个页面里面,表单根本就没提交过去,request没法获取width跟height的值
      

  5.   

    获得了,不使用
    int a =Integer.valueOf(w); 
    int b =Integer.valueOf(h);时是正常的,点提交可以显示输入的w的值
      

  6.   

    你还是没弄明白我的意思(你说的能获取,提交后的页面应该也是当前页面吧)jsp本质上就是一个Servlet,你访问的时候会先进行编译,在你第一次访问这个jsp的时候,request根本就没法获得width跟height的值,都为null,所以会产生转换错误.
      

  7.   

    req.getPa..("width")这个获取到的是空值!!!
    所以无法转换。。
      

  8.   

    如果你非要在一个页面实现那样的功能,用js可以很容易的实现
    或者你提交到另外一个jsp里面,把这个jsp复制过去
      

  9.   

    我设置了2个jsp文件,一个提交,一个处理就好了,谢谢。
    再问下,怎么样才可以把form表单和转换的程序放一个jsp文件里呢?