当前位置: 代码迷 >> Java Web开发 >> java.lang.StringIndexOutOfBoundsException
  详细解决方案

java.lang.StringIndexOutOfBoundsException

热度:833   发布时间:2010-05-13 23:04:57.0
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.util.net.AprEndpoint$Worker.run(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 java.io.*;
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  

----------------解决方案--------------------------------------------------------
贴出来的代码不是问题的出处
----------------解决方案--------------------------------------------------------
  相关解决方案