Bonjour à tous,

J'ai un nullpointerException dans ma JSP en faisant juste ceci:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
 
 
row.getCell(8).getStringCellValue();
voici ma jsp, ( en rouge la ligne à problème) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@page import="org.apache.poi.poifs.filesystem.POIFSFileSystem" %>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.FileNotFoundException"%>
<%@page import="java.io.IOException"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.ParseException"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Iterator"%>
<html><head><title>Extraction du Fichier Excel</title>
<link rel="stylesheet" type="text/css" href="style_de_base.css" media="screen">
</head>
<body>
<center><h3>Extraction IETD</h3>
<br>
</center>

<form>
<% 
String type_dossier;
String ref_presta;
String code_action;
long N_BP_Symphonie;
String Indice_Carat;
String lib_offre;
String entite;
String televendeur;
String recu = "";
String expedie ="";
String date_npai;
String anomalie;
Calendar cal1=Calendar.getInstance();
Calendar cal2=Calendar.getInstance();%><%
	   
	try{
		POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("C:/IETD_export.xls"));
		//FileInputStream fs =new FileInputStream("C:/IETD_export.xls");
	      HSSFWorkbook wb = new HSSFWorkbook(fs);
	      HSSFSheet sheet = wb.getSheetAt(0);
	      HSSFRow row = null;
	      HSSFCell cell = null;
	      int numLigne = 1;
	      int n;
	      int num;
	      DateFormat formatter ; 
	      java.util.Date dat1 ; 
	      java.util.Date dat2 ; 
	      formatter = new SimpleDateFormat("dd/MM/yyyy");
	      for (Iterator rowIt = sheet.rowIterator(); rowIt.hasNext();){
	          //totalLigne = 0;
	          row = (HSSFRow)rowIt.next();
	          //nbre total de ligne
	          n = row.getRowNum();
	          //
	          //
	     
	          //test pour eviter de lire les entetes
	          if(n!=0 && n!=2690){
	        	  if(row.getCell(8).getStringCellValue()!=""){
	         		 recu = row.getCell(8).getStringCellValue();
	 	              expedie = row.getCell(9).getStringCellValue(); 
	         		 
	 	        	  }else{
	 	        		  recu="03/01/2012";
	 		        	  expedie="03/01/2012";
	 		        	  //System.out.println("ezlijfdoiezjdloezkdokdzekdpzekdpoezkdpoekdpoezkdpoezkdpoek"+recu+expedie);
	 	        	  }
	         
	          //test pour eviter que l'une des dates soit vides et avoir un parse error de la date
	          if(recu!="" && expedie!=""){
	        	  
	          dat1 = formatter.parse(recu);
	          dat2 = formatter.parse(expedie);
	          cal1.setTime(dat1);
	          cal2.setTime(dat2);
	          //System.out.println("-----"+cal1.toString());
	          
	          int jours = 0;
	          while (cal1.before(cal2)){
	           cal1.add(Calendar.DAY_OF_MONTH,1);
	           jours++;
	          }
	          
	          //TEST
	          if(jours>2){
	          	//System.out.println(jours+" jours");
	          	%>
	          	<input type="text" name="jours" value="<%=jours%>">
	          		<%
	          	num=row.getRowNum();
	          	num++;
	          	//System.out.println("n° de la ligne : "+num);
	          	%>
	          	<input type="text" name="nligne" value="<%=num%>">
	          		<%
	              //System.out.println("Today is " +dat1 );
	          	//System.out.println("ON AFFICHE LA LIGNE !!!");
	          	%>
	          	<table>
	          	<tr><td>type_dossier</td><td>référence prestataire</td><td>code action</td><td>N_BP_Symphonie</td><td>Indice_Carat</td><td>lib_offre</td><td>entite</td>
	          	<td>televendeur</td><td>recu</td><td>expedie</td><td>date_npai</td><td>anomalie</td></tr>
	          	
	          		<%
	          	//System.out.println("type_dossier|référence prestataire|code action      |N_BP_Symphonie     " +
	          			//"|Indice_Carat|lib_offre|entite|televendeur|recu|expedie|date_npai|anomalie");
	          	
	          	type_dossier = row.getCell(0).getStringCellValue();
	          	ref_presta = row.getCell(1).getStringCellValue();
	          	code_action = row.getCell(2).getStringCellValue();
	          	N_BP_Symphonie = (long) row.getCell(3).getNumericCellValue();
	          	Indice_Carat = row.getCell(4).getStringCellValue();
	          	lib_offre = row.getCell(5).getStringCellValue();
	          	entite = row.getCell(6).getStringCellValue();
	          	televendeur = row.getCell(7).getStringCellValue();
	          	//
	          	date_npai = row.getCell(10).getStringCellValue();
	          	anomalie = row.getCell(11).getStringCellValue();
	          	%>
	          	<tr><td><%=type_dossier %></td><td><%=ref_presta %></td><td><%=code_action %></td><td><%=N_BP_Symphonie %></td><td><%=Indice_Carat %></td><td><%=lib_offre %></td><td><%=entite %></td>
	          	<td><%=televendeur %></td><td><%=recu %></td><td><%=expedie %></td><td><%=date_npai %></td><td><%=anomalie %></td></tr>
	          	</table>
	          	<%
	              //System.out.println(type_dossier+"          "+ref_presta+"       "+code_action+"         "+N_BP_Symphonie+"        "+Indice_Carat+"                   "+lib_offre+"    "+entite+"  "+televendeur+"  "+recu+"  "+expedie+"   "+"   "+date_npai+"  "+"   "+anomalie);	
	          }
	          
	          for (Iterator cellIt = row.cellIterator(); cellIt.hasNext();) {
	          	cell = (HSSFCell) cellIt.next();
	          	//System.out.println("ligne n° "+cell.getRowIndex());//avoir le numéro de ligne
	          	break;
	          }
	          //System.out.println("total ligne "+numLigne+" = "+totalLigne);
	          //totalGeneral += totalLigne;
	          numLigne++;
	        }
	        //System.out.println("total general "+totalGeneral);
	        //System.out.println("fini");
	        //System.out.println("Nbre de ligne lue: "+numLigne);
	        }
	        }
	      
	      } catch (FileNotFoundException e) {
	        e.printStackTrace();
	      } catch (IOException e) {
	        e.printStackTrace();
	      }
	      
%>
</form>
</body></html>
J'ai tous essayé coté poi, je trouve rien.
Y'a-t-il une astuce coté développement.
J'avoue que je ne suis pas un trés bon développeur...