| Author |
jsp age verification code
|
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi, In my small application , if age is >=20, it should display above20.jsp othewise below20.jsp. in index.html two field USERNAME AND AGE. I am getting below error while submitting it. HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /validuser.jsp at line 22 19: <% 20: String userid=request.getParameter("user"); 21: String agge=request.getParameter("age1"); 22: int i = Integer.parseInt("agge"); 23: 24: if (i>20) { 25: %> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) root cause please help me Thanks and Regards thomas
|
 |
Rajesh Kesarwani
Greenhorn
Joined: Apr 04, 2005
Posts: 23
|
|
Try below: Index.html file: <form action = "test.jsp"> <input type = "text" name = "userId" value = "" /> <input type = "text" name = "age" value = ""/> <input type = "submit" name = "submit" value = "Click Here"/> </form> test.jsp file: <% String userId = request.getParameter("userId"); String age = request.getParameter("age"); int agge = 0; if(age != null) { try { agge = Integer.parseInt("age"); } catch(NumberFormatException e) { // age should be intered in number } } if(agge >= 20) { %><%@include file = "above20.jsp"%><% } else { %><%@include file = "below20.jsp"%><% } %> ~Rajesh
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi Rajesh, Thank you very much for your valuable suggestion. After running you suggested code the following error was occured. HTTP Status 404 - /WebApplication6/ -------------------------------------------------------------------------------- type Status report message /WebApplication6/ description The requested resource (/WebApplication6/) is not available. -------------------------------------------------------------------------------- Apache Tomcat/6.0.16 As i am building application using Netbeans 6.0. Kindly suggest your updated view. Thanks thomas
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi Rajesh; when i use above code, the request is go to only below20.jsp page. for both age greter than 20 and less than 20 only below20.jsp get displayed.it doesnt satisfy condition. Thanks and Regards Thomas
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
"thomas", Please check your private messages. -Ben
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Shilpa Tendulkar
Ranch Hand
Joined: Jul 29, 2001
Posts: 75
|
|
|
you should have Integer.parseInt(agge); instead of, Integer.parseInt("agge");
|
SCJP5
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
"HARRY", Please check your private messages regarding an important administrative matter. -Ben
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi Shilpa; you suggested code run successfully. Now if i want to display the error page mentioning Age should be entered in Integer only, can you suggest any modification? Thank you very much. Regards HARSHAL GURAV
|
 |
Harshal Gurav
Ranch Hand
Joined: May 29, 2008
Posts: 150
|
|
Hi Shilpa; you suggested code run successfully. Now if i want to display the error page mentioning Age should be entered in Integer only, can you suggest any modification? Thank you very much. Regards HARSHAL GURAV
|
 |
 |
|
|
subject: jsp age verification code
|
|
|