Probleme d'upload de fichier
Bonjour,
J'essaye actuellement d'installer un projet que j'ai fait dans une entreprise sur mon ordinateur. Mais le probleme c'est que sur mon ordinateur ca ne marche pas (comme par hasard:( ).
C'est à priori un probleme d'upload de fichier. En effet ma jsp doit uploader des fichiers(Excel) sur un serveur et les classes Java que j'ai écrite doivent les corriger.
Le probleme c'est que à l'léxécution de la JSP j'ai cette erreur :
java.lang.IllegalArgumentException: L'index de fichier 0 est supérieur au nombre de fichiers (actuellement 0).
C'est une erreur de SmartUpload que j'utilise pour l'upload des fichiers. En entreprise j'utilisais Resine mais chez moi je suis avec Tomcat, est ce que le probleme pourrait venir de là?
Voila ma JSP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page language="java" %>
<%@page import="java.util.*, java.lang.*,java.io.*,sigle.tests.*"%>
<jsp:useBean id="myUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head>
<title>test</title>
</head>
<body bgcolor="#EDEDED">
<%!
File tmpFile;
String repertoire;
String ext;
String fichier;
%>
<%
try
{
repertoire="C:\\Program Files\\Tomcat 5.5\\webapps\\sigle" ;
myUpload.initialize(pageContext);
myUpload.upload();
String type = myUpload.getRequest().getParameter("type") ;
com.jspsmart.upload.File file = myUpload.getFiles().getFile(0) ;
ext = file.getFileExt() ;
tmpFile = File.createTempFile("tmp", "." +ext, new File(repertoire)) ;
fichier = tmpFile.getAbsolutePath() ;
if(file != null && file.getSize()>0)
{
try
{
file.saveAs(fichier) ;
}
catch(Exception e)
{
out.println("erreur : " + e.getMessage()) ;
e.printStackTrace() ;
}
}
Properties p = new Properties() ;
FileInputStream fis = new FileInputStream("C:\\Program Files\\Tomcat 5.5\\webapps\\sigle\\test.properties");
p.load(fis) ;
fis.close() ;
Properties p2 = new Properties();
FileInputStream fis2 = new FileInputStream("C:\\Program Files\\Tomcat 5.5\\webapps\\sigle\\XML.properties");
p2.load(fis2);
fis2.close();
%>
<h3>Rapport derreur du fichier <%out.println(file.getFileName());%> (de type <%out.println(type);%>)</h3>
<pre>
<%
if(type.equals("RAV"))
{
TestFichierRAV trv = new TestFichierRAV(fichier, p) ;
trv.setOut(out) ;
trv.test() ;
trv.close0() ;
}
if(type.equals("CONF"))
{
TestFichierCONF tcf = new TestFichierCONF(fichier, p) ;
tcf.setOut(out) ;
tcf.test() ;
tcf.close0() ;
}
if(type.equals("EAM"))
{
TestFichierEAM team = new TestFichierEAM(fichier, p) ;
team.setOut(out) ;
team.test() ;
team.close0() ;
}
if(type.equals("LOG"))
{
TestFichierLOG tlog= new TestFichierLOG(fichier, p) ;
tlog.setOut(out) ;
tlog.test() ;
tlog.close0() ;
}
if(type.equals("ATT"))
{
TestFichierATT tatt = new TestFichierATT(fichier, p) ;
tatt.setOut(out) ;
tatt.test() ;
tatt.close0() ;
}
if(type.equals("LTB"))
{
FichierXML fxml = new FichierXML(p2);
fxml.setOut(out);
fxml.init(fichier);
}
%>
</pre>
<%
}
catch(IllegalArgumentException e)
{
out.println("Vous n'avez pas séléctionner de fichier. :"+e);
}
catch(Exception e)
{
out.println("erreur :"+e);
e.printStackTrace() ;
}
/*if(tmpFile.exists())
{
tmpFile.delete();
}*/
%>
</body>
</html> |
Voila j'espère que vous pourrez m'aider parce que je dois présenter cette activité au BTS!!!