This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes uploading doc file Using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "uploading doc file Using jsp" Watch "uploading doc file Using jsp" New topic
Author

uploading doc file Using jsp

aashu sahu
Greenhorn

Joined: Aug 02, 2012
Posts: 1
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: uploading doc file Using jsp
 
Similar Threads
creating website basic question
whats wrong with this code?
Unable to compile class for JSP
Unable to load tag handler class "com.opensymphony.webwork.views.jsp.PropertyTag
how to apply theme as ajax to the jsp form with struts2-core-2.1.6.jar used struts 2 application ?