| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 679 人关注过本帖
标题:java.lang.StringIndexOutOfBoundsException
只看楼主 加入收藏
tianbian210
Rank: 1
等 级:新手上路
帖 子:46
专家分:1
注 册:2008-12-25
结帖率:87.5%
收藏
已结贴  问题点数:20 回复次数:1 
java.lang.StringIndexOutOfBoundsException
严重: Servlet.service() for servlet sys.active threw exception
java.lang.StringIndexOutOfBoundsException: String index out of range: 19
    at java.lang.String.substring(String.java:1935)
    at org.apache.jsp.sys.active_jsp._jspService(active_jsp.java:159)
    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:377)
    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at com.sys.Active.doPost(Active.java:58)
    at com.sys.Active.doGet(Active.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    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:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.(AprEndpoint.java:1555)
    at java.lang.Thread.run(Thread.java:619)

页面代码:
/*
 * Created on 2008-1-24
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.sys;

import oa.sys.*;
import oa.data.*;
import java.util.*;
import *;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 ****************************************************
 *类名称:    Active<br>
 *类功能:    激活账号(类型)<br>
 ****************************************************
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class Active extends HttpServlet{
    private String password;
    private String time;
    private Statement stmt;
    private ResultSet rs;
    private RequestDispatcher dispatcher;
    private int id=0;
   
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
        request.setCharacterEncoding("gb2312");
        response.setContentType("text/html; charset=gb2312");
        Db db=new Db();
        Str str=new Str();
        Collection ret=new ArrayList();
        PrintWriter out=response.getWriter();
        try{
            stmt=db.getStmtread();
            rs=stmt.executeQuery("SELECT * FROM password");
            while(rs.next()){
                id=rs.getInt(1);
                password=rs.getString(2);
                time=rs.getString(3);
                Password pass=new Password();
                pass.setId(id);
                pass.setPassword(password);
                pass.setTime(time);
                ret.add(pass);
            }
                request.setAttribute("msg",ret);
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            db.close();
            dispatcher=request.getRequestDispatcher("active.jsp");
            dispatcher.forward(request,response);
        }
    }
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
       doPost(request,response);
    }
}
搜索更多相关主题的帖子: java lang 
2010-05-13 23:04
baifenghan
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:258
专家分:952
注 册:2006-3-17
收藏
得分:20 
贴出来的代码不是问题的出处
2010-05-14 21:02
快速回复:java.lang.StringIndexOutOfBoundsException
数据加载中...
 
   



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

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