|
||||||
| Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I have a JSP (JSP1) with 3 forms:
1st) is part of the jsp and works correctly 2nd) is part of the jsp and sends a request to an external JSP (JSP2) 3rd) JSP2 is included inside JSP1 JSP2 receives a character from the 2nd form (radio buttons with a character associated) and performs a query on a DB searching items with that character as initial (the query works correctlly), the result of the query is a form which contains a table included in JSP1. I insert some values in the text fields of this included form, click the submit button and the servlet does its work updating the DB with the new values. After the update the servlet reloads JSP1. Everything correct till this point. The problem is, if now I click on a radio button Tomcat returns an error: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception java.lang.NumberFormatException: null java.lang.Integer.parseInt(Unknown Source) java.lang.Integer.parseInt(Unknown Source) frontend.ModificaRimanenza.doPost(ModificaRimanenz a.java:30) javax.servlet.http.HttpServlet.service(HttpServlet .java:710) javax.servlet.http.HttpServlet.service(HttpServlet .java:803) When I click on the radio button things go as I also click the submit button in the included form and a null value is sent to the servlet ModificaRimanenza, which is associated to the external form, not to the radio buttons form. Why this happens? JSP1 code HTML Code:
<%@ page language="java" contentType="text/html; charset=iso-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="controller.MagController" %> <%! static final String[][] TABS = { {"A","showingrediente.jsp"}, {"B","showingrediente.jsp"}, {"C","showingrediente.jsp"} <!-- and so on till Z --> };%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Modifica soglia</title> <% int soglia_scadenza = MagController.getSoglia(); %> <SCRIPT LANGUAGE="JavaScript"> <!-- function checkSogliaScadenza(obj) { //permette solo numeri scadenza = obj.value.replace(/\D/g,""); obj.value = scadenza; } function checkFormScadenza(obj) { if(document.modsoglia.scadenza.value <= 0) { alert("La soglia di scadenza deve essere un intero maggiore di 1"); document.modsoglia.scadenza.value = ""; document.modsoglia.scadenza.focus(); return false; } return true; } //--> </script> </head> <body> <center> <h2>Modifica valori di soglia</h2> <br><br> Modifica soglia di scadenza <form name="modsoglia" action="ModificaScadenza" method="post"> <table width="300" border="0" cellpadding="6"> <tr> <td width="65%">Soglia per date di scadenza</td> <td width="35%"> <%= soglia_scadenza %> giorni</td> </tr> <tr> <td>Nuovo valore di soglia</td> <td><input type="text" name="scadenza" size="3" onChange="checkSogliaScadenza(this)" /> giorni</td> </tr> <tr> <td><%if (session.getAttribute("esito_scadenza") != null) if (session.getAttribute("esito_scadenza").equals("non_modificata")) {%> <font color="red">Soglia non modificata!</font> <% } %></td> <td><input type="submit" name="modsoglia" value="Modifica" onClick="return checkFormScadenza(this)"/></td> </tr> </table> </form> <br><br><br> Modifica soglia rimanenze<br> <form action="" method="post"> <%String which = request.getParameter("which"); if (which==null) which = TABS[0][0]; String jspToRun = null; for (int i=0; i<TABS.length; i++) { String tabLabel = TABS[i][0]; String tabJSP = TABS[i][1]; String CHECKED = ""; if (which.equals(tabLabel)) { CHECKED = "CHECKED"; jspToRun = tabJSP; } %> <input name="which" type="radio" value="<%=tabLabel %>" <%= CHECKED %> onClick="this.form.submit()" /><%= tabLabel %> <% if (i==12) {%> <br> <% } } %> </form> <jsp:include page="<%= jspToRun %>" flush="true" /> <br><br><br><br> <a href="hpmagazziniere.html">Home page</a> </center> </body> </html> HTML Code:
<%@ page import="controller.IngrController" %> <%@ page import="java.sql.*" %> <SCRIPT LANGUAGE="JavaScript"> <!-- function selezionato(obj) { //permette solo numeri nuovaSoglia = obj.value.replace(/\D/g,""); obj.value = nuovaSoglia; if(obj.value > 0) document.modrimanenza.totale_selezionati.value = parseInt(document.modrimanenza.totale_selezionati.value) + 1; if(obj.value <= 0) document.modrimanenza.totale_selezionati.value = parseInt(document.modrimanenza.totale_selezionati.value) - 1; } function checkForm() { if (document.modrimanenza.totale_selezionati.value == 0) return false; else return true; } //--> </script> <% int i=0; String lettera = request.getParameter("which"); ResultSet rs = IngrController.getIngrMagPerLettera(lettera); %> <center> <form name="modrimanenza" action="ModificaRimanenza" method="post"> <table width="550" cellpadding="2"> <tr> <td width="25%"><b>Ingrediente</b></td> <td width="20%"><b>Unità di misura </b></td> <td width="25%"><div align=center><b>Soglia attuale </b></div></td> <td width="30%"><b>Nuovo valore di soglia </b></td> </tr> <% while (rs.next()) { %> <tr> <td><%=rs.getString("Nome") %></td> <td><div align="center"><%=rs.getString("unitaDiMisura") %></div></td> <td><div align="center"><%=rs.getString("Soglia") %></div></td> <td><div align="center"><input type="text" name="ingrediente<%= i %>value" size="3" value="0" onChange="selezionato(this)"/></div> <input type="hidden" name="ingrediente<%= i %>name" value="<%=rs.getString("Nome") %>" /></td> </tr> <% i++; } %> <tr> <td> </td> <td> </td> <td><input type="hidden" name="totale_selezionati" value="0"/> </td> <td><div align="center"><input type="submit" name="modifica" value="Modifica" onClick="return checkForm()"/></div></td> </tr> </table> </form> </center> PHP Code:
|
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VB2008 Tutorial - Print Screen | travy92 | VB Tutorials | 22 | 11-20-2008 01:02 PM |
| Coding a change password form | InternetGeek | Visual Basic Programming | 11 | 02-16-2008 02:53 PM |
| Windows form question (select a value from childform and populate in parent form) | yasinirshad | Visual Basic Programming | 1 | 11-19-2007 12:42 PM |
| Calling a form from another form | Void | Managed C++ | 1 | 07-01-2006 10:44 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |