今、私はEclipseブラウザで次のエラーを示すエラーに悩まされています.エラーは次のようになります:
13:53:12,294 INFO [STDOUT] 30
13:53:12,294 ERROR [[Expthsmon]] Servlet.service() for servlet Expthsmon threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Expthsmon.doGet(Expthsmon.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
コードのこの部分は
int amountofnoon=0;
int amountofafternoon=0;
int noofnoon=0;
int noofafternoon=0;
String amountnoon=null;
String amountafternoon=null;
amountnoon=request.getParameter("amountnoon");
amountafternoon=request.getParameter("amountafternoon");
//if((amountnoon !=null )&&(amountafternoon !=null))
amountofnoon=Integer.parseInt(amountnoon);
System.out.println(""+amountofnoon);
amountofafternoon=Integer.parseInt(amountafternoon);
System.out.println(""+amountofafternoon);
amountofnoon と amountofafternoon が整数値でなければならないという問題が発生しています。どうすればよいですか?
また、値を取得する場所からコードの jsp 部分を追加しています。
<form name="expenditurefthsmon" action="Expthsmon">
<div align="center">Enter The Amount of Days Expenditure</div>
<div align="center"><input type="text" name="amountnoon"></input></div>
<div align="center">Enter The Amount of Nights Expenditure</div>
<div align="center"><input type="text" name=amountafternoon"></input></div>
<div align="center"><input type="submit" value="Calculate"></input></div>"
</form>