• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp age verification code

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"thomas",
Please check your private messages.
-Ben
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you should have Integer.parseInt(agge); instead of, Integer.parseInt("agge");
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"HARRY",
Please check your private messages regarding an important administrative matter.
-Ben
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic