Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uploading doc file Using jsp

 
aashu sahu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all m using eclipse as IDE and developing an jsp to upload an doc file. I'm getting an string index out of range exception...... :cry:
Here is code


help me out........
Regards,
rockydroid




getting exception:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /insert.jsp at line 50

47: }
48: String file = new String(dataBytes);
49: saveFile = file.substring(file.indexOf("filename=\"") + 10);
50: saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
51: saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
52: int lastIndex = contentType.lastIndexOf("=");
53: String boundary = contentType.substring(lastIndex + 1,contentType.length());


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.String.substring(Unknown Source)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic