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 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]
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/give-error-in-upload-a-image-in-tomcat-6-but-works-well-in-tomcat-4-tp17822463p18213863.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]

Reply via email to