Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp age verification code

 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • 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
 
Rajesh Kesarwani
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should have Integer.parseInt(agge); instead of, Integer.parseInt("agge");
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic