Re: give error in upload a image in tomcat 6 but works well in tomcat 4
sur_1805 schrieb: I am using tomcat 4 and write jsp page to upload a image in server it works with tomcat 4 but it gives error in upload image in tomcat 6 with the same jsp page .It gives some java.lang.IndexOutOfBoundsException If you are using 6.0.16 and the size of the uploaded images os biger than 8KB, it might be related to BZ 44494 https://issues.apache.org/bugzilla/show_bug.cgi?id=44494 which will be fixed in 6.0.17. Try 6.0.14 in the meantime. Not sure, if your problem is related, but could be worth a try. Regards, Rainer - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: give error in upload a image in tomcat 6 but works well in tomcat 4
but i m not using windows i m working on linux, and i had given the full path... Walter Thompson wrote: > > I have run into a simular problem going from Tomcat 5 to Tomcat 6, I had > to set many of the file paths as absolute. > > Try changing : > > save_File ="/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + > saveFile; > > To : > > save_File ="C:(Plus anything in front > of)/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + saveFile; > > Change so that the file path is set from the drive, directories, > subdirectories to the final destination. > > > > -Original Message- > From: sur_1805 [mailto:[EMAIL PROTECTED] > Sent: Friday, June 13, 2008 7:39 AM > To: users@tomcat.apache.org > Subject: give error in upload a image in tomcat 6 but works well in > tomcat 4 > > > I am using tomcat 4 and write jsp page to upload a image in server it > works with tomcat 4 but it gives error in upload image in tomcat 6 with > the same jsp page .It gives some java.lang.IndexOutOfBoundsException > at > -- > > org.apache.jasper.JasperException: An exception occurred processing JSP > page /Jsp/BOG/upload_scan.jsp at line 154 > > 151: > 152: // creating a new file with the same name and writing > the content in > new file > 153: FileOutputStream fileOut = new > FileOutputStream(save_File); > 154: fileOut.write(dataBytes, startPos, (endPos - startPos)); > 155: fileOut.flush(); > 156: fileOut.close(); > 157: > > > the code snippets is given below > > if ((contentType != null) && (contentType.indexOf("multipart/form-data") >>= > 0)) { > DataInputStream in = new > DataInputStream(request.getInputStream()); > > //we are taking the length of Content type data > > int formDataLength = request.getContentLength(); > byte dataBytes[] = new byte[formDataLength]; > int byteRead = 0; > int totalBytesRead = 0; > > //this loop converting the uploaded file into byte code > while (totalBytesRead < formDataLength) { > byteRead = in.read(dataBytes, > totalBytesRead,formDataLength); > totalBytesRead += byteRead; > } > > String file = new String(dataBytes); > //for saving the file name >saveFile = file.substring(file.indexOf("filename=\"") + > 10); > > > saveFile = saveFile.substring(0, > saveFile.indexOf("\n")); > saveFile = saveFile.substring(saveFile.lastIndexOf("\\") > + 1,saveFile.indexOf("\"")); > String extension = > saveFile.substring(saveFile.lastIndexOf(".")); > > int count=0; > String sql = "select count(table_id) from bog_table where met_key='" + > key+"' and item_id='"+item+"'"; > > ResultSet rt=null; > //out.println(sql); > rt = am.fetchRecordSet(sql); > String table_id=""; > String table_ref=""; > if(rt.next()){ > > > count=rt.getInt(1)+1; > >table_id="TableId-" + count; > table_ref= > key+"-"+item+"-"+table_id+"-TableRef-" +count; > > } > saveFile = table_ref + extension; >save_File ="/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + > saveFile; > > int lastIndex = contentType.lastIndexOf("="); > String boundary = contentType.substring(lastIndex + > 1,contentType.length()); > int pos; > //extracting the index of file > pos = file.indexOf("filename=\""); > pos = file.indexOf("\n", pos) + 1; > > pos = file.indexOf("\n", pos) + 1; > pos = file.indexOf("\n", pos) + 1; > > int boundaryLocation = file.indexOf(boundary, pos) - 4; > int startPos = ((file.substring(0, > pos)).getBytes()).length; > int endPos = ((file.substring(0, > boundaryLocation)).getBytes()).length; > > // creating a new fil
Re: give error in upload a image in tomcat 6 but works well in tomcat 4
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 sur, sur_1805 wrote: | I am using tomcat 4 and write jsp page to upload a image in server it works | with tomcat 4 but it gives error in upload image in tomcat 6 with the same | jsp page .It gives some java.lang.IndexOutOfBoundsException Care to post the stack trace? Specific Tomcat version? | org.apache.jasper.JasperException: An exception occurred processing JSP page | /Jsp/BOG/upload_scan.jsp at line 154 | | 151: | 152: // creating a new file with the same name and writing the content in | new file | 153: FileOutputStream fileOut = new FileOutputStream(save_File); | 154: fileOut.write(dataBytes, startPos, (endPos - startPos)); | 155: fileOut.flush(); | 156: fileOut.close(); | 157: This looks like a JSP compiler error, not a stack trace. What is that up there? | the code snippets is given below [snip] | int lastIndex = contentType.lastIndexOf("="); | String boundary = contentType.substring(lastIndex + | 1,contentType.length()); | int pos; | //extracting the index of file | pos = file.indexOf("filename=\""); | pos = file.indexOf("\n", pos) + 1; | | pos = file.indexOf("\n", pos) + 1; | pos = file.indexOf("\n", pos) + 1; | | int boundaryLocation = file.indexOf(boundary, pos) - 4; | int startPos = ((file.substring(0, pos)).getBytes()).length; | int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; | | // creating a new file with the same name and writing the content in new | file | FileOutputStream fileOut = new FileOutputStream(save_File); | fileOut.write(dataBytes, startPos, (endPos - startPos)); | fileOut.flush(); | fileOut.close(); dataBytes, startPos, and endPos appear to have no relationship to each other. dataBytes is presumably the content of the file being posted, and startPos and endPos are clearly indexes into the 'file' string. It seems more natural to loop over the input and dump it into the output, instead of reading the entire file into memory and then writing to the output file. Perhaps you have some requirements I do not understand. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkhSqRQACgkQ9CaO5/Lv0PDEvACgidQDejpRuxM/8TjPfkVPlwzP QyUAoJhhcF/wL9buI5+m2RAW/mGu1gtr =QTcH -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: give error in upload a image in tomcat 6 but works well in tomcat 4
I have run into a simular problem going from Tomcat 5 to Tomcat 6, I had to set many of the file paths as absolute. Try changing : save_File ="/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + saveFile; To : save_File ="C:(Plus anything in front of)/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + saveFile; Change so that the file path is set from the drive, directories, subdirectories to the final destination. -Original Message- From: sur_1805 [mailto:[EMAIL PROTECTED] Sent: Friday, June 13, 2008 7:39 AM To: users@tomcat.apache.org Subject: give error in upload a image in tomcat 6 but works well in tomcat 4 I am using tomcat 4 and write jsp page to upload a image in server it works with tomcat 4 but it gives error in upload image in tomcat 6 with the same jsp page .It gives some java.lang.IndexOutOfBoundsException at -- org.apache.jasper.JasperException: An exception occurred processing JSP page /Jsp/BOG/upload_scan.jsp at line 154 151: 152:// creating a new file with the same name and writing the content in new file 153:FileOutputStream fileOut = new FileOutputStream(save_File); 154:fileOut.write(dataBytes, startPos, (endPos - startPos)); 155:fileOut.flush(); 156:fileOut.close(); 157: the code snippets is given below if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { DataInputStream in = new DataInputStream(request.getInputStream()); //we are taking the length of Content type data int formDataLength = request.getContentLength(); byte dataBytes[] = new byte[formDataLength]; int byteRead = 0; int totalBytesRead = 0; //this loop converting the uploaded file into byte code while (totalBytesRead < formDataLength) { byteRead = in.read(dataBytes, totalBytesRead,formDataLength); totalBytesRead += byteRead; } String file = new String(dataBytes); //for saving the file name saveFile = file.substring(file.indexOf("filename=\"") + 10); saveFile = saveFile.substring(0, saveFile.indexOf("\n")); saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\"")); String extension = saveFile.substring(saveFile.lastIndexOf(".")); int count=0; String sql = "select count(table_id) from bog_table where met_key='" + key+"' and item_id='"+item+"'"; ResultSet rt=null; //out.println(sql); rt = am.fetchRecordSet(sql); String table_id=""; String table_ref=""; if(rt.next()){ count=rt.getInt(1)+1; table_id="TableId-" + count; table_ref= key+"-"+item+"-"+table_id+"-TableRef-" +count; } saveFile = table_ref + extension; save_File ="/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + saveFile; int lastIndex = contentType.lastIndexOf("="); String boundary = contentType.substring(lastIndex + 1,contentType.length()); int pos; //extracting the index of file pos = file.indexOf("filename=\""); pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; int boundaryLocation = file.indexOf(boundary, pos) - 4; int startPos = ((file.substring(0, pos)).getBytes()).length; int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; // creating a new file with the same name and writing the content in new file FileOutputStream fileOut = new FileOutputStream(save_File); fileOut.write(dataBytes, startPos, (endPos - startPos)); fileOut.flush(); fileOut.close(); || please give me the solution -- View this message in context: http://www.nabble.com/give-error-in-upload-a-image-in-tomcat-6-but-works -well-in-tomcat-4-tp17822463p17822463.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tom
give error in upload a image in tomcat 6 but works well in tomcat 4
I am using tomcat 4 and write jsp page to upload a image in server it works with tomcat 4 but it gives error in upload image in tomcat 6 with the same jsp page .It gives some java.lang.IndexOutOfBoundsException at -- org.apache.jasper.JasperException: An exception occurred processing JSP page /Jsp/BOG/upload_scan.jsp at line 154 151: 152:// creating a new file with the same name and writing the content in new file 153:FileOutputStream fileOut = new FileOutputStream(save_File); 154:fileOut.write(dataBytes, startPos, (endPos - startPos)); 155:fileOut.flush(); 156:fileOut.close(); 157: the code snippets is given below if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { DataInputStream in = new DataInputStream(request.getInputStream()); //we are taking the length of Content type data int formDataLength = request.getContentLength(); byte dataBytes[] = new byte[formDataLength]; int byteRead = 0; int totalBytesRead = 0; //this loop converting the uploaded file into byte code while (totalBytesRead < formDataLength) { byteRead = in.read(dataBytes, totalBytesRead,formDataLength); totalBytesRead += byteRead; } String file = new String(dataBytes); //for saving the file name saveFile = file.substring(file.indexOf("filename=\"") + 10); saveFile = saveFile.substring(0, saveFile.indexOf("\n")); saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\"")); String extension = saveFile.substring(saveFile.lastIndexOf(".")); int count=0; String sql = "select count(table_id) from bog_table where met_key='" + key+"' and item_id='"+item+"'"; ResultSet rt=null; //out.println(sql); rt = am.fetchRecordSet(sql); String table_id=""; String table_ref=""; if(rt.next()){ count=rt.getInt(1)+1; table_id="TableId-" + count; table_ref= key+"-"+item+"-"+table_id+"-TableRef-" +count; } saveFile = table_ref + extension; save_File ="/data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/" + saveFile; int lastIndex = contentType.lastIndexOf("="); String boundary = contentType.substring(lastIndex + 1,contentType.length()); int pos; //extracting the index of file pos = file.indexOf("filename=\""); pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; pos = file.indexOf("\n", pos) + 1; int boundaryLocation = file.indexOf(boundary, pos) - 4; int startPos = ((file.substring(0, pos)).getBytes()).length; int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length; // creating a new file with the same name and writing the content in new file FileOutputStream fileOut = new FileOutputStream(save_File); fileOut.write(dataBytes, startPos, (endPos - startPos)); fileOut.flush(); fileOut.close(); || please give me the solution -- View this message in context: http://www.nabble.com/give-error-in-upload-a-image-in-tomcat-6-but-works-well-in-tomcat-4-tp17822463p17822463.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
give error in upload a image in tomcat 6 but works well in tomcat 4
-- View this message in context: http://www.nabble.com/give-error-in-upload-a-image-in-tomcat-6-but-works-well-in-tomcat-4-tp17822410p17822410.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]