IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

NullPointerException sur ma JSP


Sujet :

Servlets/JSP Java

  1. #1
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut NullPointerException sur ma JSP
    Bonsoir à tous,

    Je me retrouve avec un :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Servlet.service() for servlet [jsp] in context with path [/PTI2-HistoBioLabo] threw exception [java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    Je ne comprend pas ce charabia, help !!


    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
    26 janv. 2012 17:50:03 org.apache.catalina.core.StandardWrapperValve invoke
    GRAVE: Servlet.service() for servlet [jsp] in context with path [/PTI2-HistoBioLabo] threw exception [java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    	at org.apache.jsp.readExcel_jsp._jspService(readExcel_jsp.java:141)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

  2. #2
    Membre émérite
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Points : 2 969
    Points
    2 969
    Par défaut
    Bonjour,

    Il nous faudrait le code de la JSP pour pouvoir t'aider
    Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

    F.A.Q. : Java, PHP, (X)HTML / CSS

    N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème

  3. #3
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    tu déférence un pointeur null en readExcel_jsp.java ligne 141. Faut maintenant aller regarde ce qui se passe là bas

  4. #4
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    Maintenant, j'ai ce message d'erreur ci.

    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
    org.apache.jasper.JasperException: An exception occurred processing JSP page /readExcel.jsp at line 65
     
    62: 	     
    63: 	          //test pour eviter de lire les entetes
    64: 	          if(n!=0){
    65: 	        	  recu = row.getCell(8).getStringCellValue();
    66: 	              expedie = row.getCell(9).getStringCellValue();
    67: 	             
    68: 	         
     
     
    Stacktrace:
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
     
    cause mère
     
    java.lang.NullPointerException
    	org.apache.jsp.readExcel_jsp._jspService(readExcel_jsp.java:142)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    Apparemment, c'est 2 là font beaucoup de bruit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    recu = row.getCell(8).getStringCellValue();
    expedie = row.getCell(9).getStringCellValue();
    ceci, renvoirai le 'Nullpointer'
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    row.getCell(8).getStringCellValue();
    alors que je fais un test juste après:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    if(n!=0){
    	        	 
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    12
     recu = row.getCell(8).getStringCellValue();
    	              expedie = row.getCell(9).getStringCellValue();
    //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);
    Je cherche mais j'ai pas trouvé. Peut-être qu'il y'a une fonction qui permet de contourner un NullPointer ou une astuce de développer

    ma jsp readExcel.jsp (en rouge, les lignes qui font du bruit )
    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
    <%@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 = "04/01/2012";
    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){
    	        	 
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    12
     recu = row.getCell(8).getStringCellValue();
    	              expedie = row.getCell(9).getStringCellValue();
    //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>

  5. #5
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    a priori, je dirais soit que row est null, soit que row.getCell() renvoie null. Le test après ça ne sert à rien, c'est avant qu'il faut les faire

  6. #6
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    Thank you
    Thank you Thank you ....
    I love you

    allez, Je t'invite a déjeuner !!

  7. #7
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Bon, ça vient? J'ai faim!

  8. #8
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    Si t'est sur paris ou région parisienne, je t'invite sinon je t'envoie un cadeau donne ton adresse en mp !

  9. #9
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    ça ira, j'ai peur que le jambon beurre soit suspect après une livraison postale

  10. #10
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    lol !
    des sucreries du genre nougat, pistache, tant que t pas allergique ca va
    merci en tout cas, c'étais ce qu'il me fallait pour finir la semaine trankilll


+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Pb de lien sur un jsp
    Par yubaba dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 05/12/2006, 09h34
  2. affichage d'une donnée de bean sur une jsp
    Par freestyler1982 dans le forum Struts 1
    Réponses: 1
    Dernier message: 09/11/2006, 10h02
  3. Passer paramètres d'un formulaire sur plusieurs JSP
    Par itr dans le forum Servlets/JSP
    Réponses: 5
    Dernier message: 02/05/2006, 17h42
  4. [struts]plusieurs actions sur 1 JSP sans DispatchAction
    Par Le Marlou dans le forum Servlets/JSP
    Réponses: 15
    Dernier message: 23/03/2005, 14h10
  5. [debutant]renvoyer sur une jsp depuis une servlet
    Par omega dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 23/03/2004, 11h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo