-----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]

Reply via email to