Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

usage of if condition  RSS feed

 
Avinash Nethi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam not getting output by compiling this jsp code in tomcat5.5.20version
---------------this is the code--------------
1.form.html
<body bgcolor="cyan">
<form method=get action=\jspSeven\btech.html>
<b>Only B.tech people are Eligible</b>
<bR><br>
<b>Mandatory Percentages to Enter into an MNC Company</b>
<br><br>
Enter Your Name:<input type=text name=name>
<br><Br>
Enter Your Qualification:<input type=text name=qual>
<br><br>
<input type=submit name=send value=SEND>
</form>
</body>
2.btech.html
<body bgcolor="yellow">
<form method=get action=\jspSeven\second.jsp>
<CEnter><b>
Enter your percentages</b></center>
<br><br>
Enter your percentage in S.S.C/Xth:<input type=text name=ssc>
<br><BR>
Enter your percentage in Intermediate/xIIth :<input type=text name=boi>
<br><BR>
Enter your percentage in B.Tech:<input type=text name=btech>
<input type=submit name=send value=SEND>
</form>
</body>
3.second.jsp
<body bgcolor="green">
<center><u><b>Verification for the Eligibility of test</b></u></center>
<%
String ssc=request.getParameter("ssc");
String boi=request.getParameter("boi");
String btech=request.getParameter("btech");
%>
<br><br>
<%
{
if(ssc>=60 && boi>=60 && btech>=60)
out.println("Congratulations you are Eligible to apply for the test");
else
out.println("sorry you are not qualified to apply for the test");
}
%>
</center>
</body>
-----------code completed--------------------
Please help me iam facing with the problem of condition and control statements in jsp application to run in tomcat 5.5.20 version.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "the problem of condition and control statements"?

One problem is certainly that you're trying to apply numerical comparison operators (namely, ">=") to strings. You can only apply those to numbers. If you're certain that the strings in question contain numbers, you can convert them to numbers using Integer.parseInt. Make sure you add proper exception handling.

As an aside, this kind of Java code has no place in JSPs. You should use a servlet or backing bean to perform any computations, and use JSPs only for displaying the results.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!