| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1726 人关注过本帖
标题:新学JSP,调试.JSP文件遇到问题,求教严重: Servlet.service() for servlet ...
只看楼主 加入收藏
孙宝磊
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-4-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
新学JSP,调试.JSP文件遇到问题,求教严重: Servlet.service() for servlet jsp threw exception
<%@ page contentType="text/html;charset=GB2312" language="java"%>
<%@ page info="用户注册"%>
<%
  //获取用户信息
  String username = request.getParameter("username");
  String pwd      = request.getParameter("pwd1");
  String year     = request.getParameter("year");
  String month    = request.getParameter("month");
  String day      = request.getParameter("day");
  String sex      = request.getParameter("sex");
  String email    = request.getParameter("email");
  String interest = request.getParameter("interest");
  //代码转换
  interest = new String(interest.getBytes("ISO8859_1"),"GBK");
  sex = new String(sex.getBytes("ISO8859_1"),"GBK");
  username = new String(username.getBytes("ISO8859_1"),"GBK");
%>
<html>
  <head>
    <title></title>
  </head>
  <body>
  <%
    //显示用户注册的信息
    out.print("恭喜您注册成功!以下是您的注册信息:<p>");
    out.print("用户名:"+username+"<br>");
    out.print("出生日期:"+year+"年"+month+"月"+day+"日"+"<br>");
    out.print("性别:"+sex+"<br>");
    out.print("邮箱:"+email+"<br>");
    out.print("兴趣:"+interest+"<br>");
  %>
  </body>
</html>代码是这样的,HTML文件没问题,编译.JSP文件提示以下问题
2013-4-27 22:06:11 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.23 using APR version 1.4.6.
2013-4-27 22:06:11 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2013-4-27 22:06:13 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized with version OpenSSL 1.0.0g 18 Jan 2012
2013-4-27 22:06:16 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-4-27 22:06:16 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2013-4-27 22:06:16 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 9618 ms
2013-4-27 22:06:16 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-4-27 22:06:16 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.36
2013-4-27 22:06:18 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor test.xml
2013-4-27 22:06:18 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-4-27 22:06:18 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2013-4-27 22:06:18 org.apache.catalina.startup.Catalina start
信息: Server startup in 2449 ms
2013-4-27 22:06:22 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.register_jsp._jspService(register_jsp.java:70)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600)
    at org.apache.tomcat.(AprEndpoint.java:1703)
    at java.lang.Thread.run(Unknown Source)
附HTML<html>
<head>
<title>用户注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script>
function check(){
  username=document.form1.username.value;
  <!--username=document.forms[0].username.value;-->
  pwd1=document.form1.pwd1.value;
  pwd2=document.form1.pwd2.value;
  year=document.form1.year.value;
  month=document.form1.month.value;
  day=document.form1.day.value;
  email=document.form1.email.value;
  interest=document.form1.interest.value;

  if(username.length<6||username.length>15){
    //检查用户名是否在指定的范围之内
    alert("用户名长度必须在6~15位之间!");
    return false;
  }
  if(pwd1.length<6||pwd1.length>20){
    //检查密码是否在指定的范围之内
    alert("密码长度必须在6~15位之间!");
    return false;
  }
  if(pwd1!=pwd2){
    //检查密码和确认密码是否相同
    alert("密码不匹配!")
    return false;
  }
  if(year.length!=4||month>13||month<1||day>32||day<1){
    //检查生日格式是否正确
    alert("生日输入不正确!")
    return false;
  }
  if(email=""||(email.indexOf('@')==-1)||(email.indexOf('.')==-1)){
    //检查电子邮件格式是否正确
    alert("电子邮箱格式不正确!")
    return false;
  }

  return true;
}
</script>

<body bgcolor="#FFFFFF" text="#000000">

<p align="center">请输入注册信息</p>
<form name="form1" method="post" action="register.jsp" OnSubmit="return check();">
  <table width="36%" border="1" cellspacing="1" cellpadding="1" align="center" height="160">
    <tr>
      <td width="45%">用户名(6-15位)</td>
      <td width="55%">
        <input type="text" name="username" size="15">
      </td>
    </tr>
    <tr>
      <td width="45%">密码(6-10位)</td>
      <td width="55%">
        <input type="password" name="pwd1" size="10">
      </td>
    </tr>
    <tr>
      <td width="45%">确认密码</td>
      <td width="55%">
        <input type="password" name="pwd2" size="10">
      </td>
    </tr>
    <tr>
      <td width="45%">出生日期</td>
      <td width="55%">
        <input type="text" name="year" size="4">
        
        <input type="text" name="month" size="2">
        
        <input type="text" name="day" size="2">
        日</td>
    </tr>
    <tr>
      <td width="45%">性别</td>
      <td width="55%">
        <input type="radio" name="gender" value="男" checked>
        
        <input type="radio" name="gender" value="女">
        女</td>
    </tr>
    <tr>
      <td width="45%">电子邮件</td>
      <td width="55%">
        <input type="text" name="email" size="20">
      </td>
    </tr>
    <tr>
      <td width="45%">爱好</td>
      <td width="55%">
        <input type="text" name="interest" size="20">
      </td>
    </tr>
  </table>
  <p align="center">
    <input type="submit" name="Submit" value="提交">
    <input type="reset" name="Submit2" value="重置">
  </p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
搜索更多相关主题的帖子: email exception interest 用户 
2013-04-27 22:47
星112
Rank: 5Rank: 5
来 自:山西朔州
等 级:职业侠客
威 望:2
帖 子:94
专家分:342
注 册:2012-6-22
收藏
得分:20 
空指针但不进行调试吧,看看哪个值没取到...
2013-04-29 14:00
星112
Rank: 5Rank: 5
来 自:山西朔州
等 级:职业侠客
威 望:2
帖 子:94
专家分:342
注 册:2012-6-22
收藏
得分:0 
空指针进行调试吧,看看哪个值为空啊....
2013-04-29 14:01
gaigelovelgg
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-7-5
收藏
得分:0 
你去你配置的tomcat下的文件下找到register_jsp.java:70,比如我的D:\apache-tomcat-6.0.32-windows-x86\tomcat-6.0\work\Catalina\localhost\_\org\apache\jsp,找到你的register_jsp.java:70第70行 看哪个出现的空指针问题
2013-07-05 11:01
快速回复:新学JSP,调试.JSP文件遇到问题,求教严重: Servlet.service() for se ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040234 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved