JSTL - check odd/even number

Ads

 
 

Share on Google+Share on Google+

Ernie
JSTL - check odd/even number
1 Answer(s)      7 years ago
Posted in : JSP-Servlet
Ads
View Answers

November 10, 2009 at 4:38 PM


Hi Friend,

Try the following code:

<%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
<%@ page import="java.util.*"%>
<% Random r=new Random();
int num = r.nextInt(100);
System.out.println(num);
int pno=num-1;
int nno=num+1;
%>
<html>
<body>
<form method="post">Random Number:<input type="hidden" name="number" value="<%=num%>" />
<input type="submit" value="Accept" />
</form>
<c:if test="${pageContext.request.method=='POST'}">Random number is: <%=num%>
<c:choose>
<c:when test="${param.number%2==0}">It is an even number lies between <%=pno%> and <%=nno%>.
<br />
</c:when>
<c:otherwise>It is an odd number lies between <%=pno%> and <%=nno%>.
<br />
</c:otherwise>
</c:choose>
</c:if>
</body>
</html>

For more information, visit the following link:
http://www.roseindia.net/jsp/jsp-jstl-c-when-tag.shtml

Thanks

Ads









Related Tutorials/Questions & Answers:
Odd Even Transposition Sort In Java
pair off either the odd or even neighboring pairs. Each number (In Processing... Odd Even Transposition Sort In Java   ... In this example we are going to sort integer values of an array using odd even
odd and even
odd and even  how can i make a program of even and odd using case...{ System.out.println(); System.out.println("1 Display Even"); System.out.println("2 Display Odd"); System.out.println("3 Exit"); System.out.print("Choose
Advertisements
JSTL
JSTL  How to remove element from list one by one in jsp using jstl tag? My requirement is, i want to remove a element from selectlist, that element should not appear in the next followed select list, which is hided
An Introduction to JSTL
JSTL Core Tags The JSTL encapsulates the core functionality which is common to many web applications. The JSTL provides a single set of tags instead of mixing many set of tags. The JSTL have tags for loop statement, If Else statement
JSP JSTL c:when tag
, a message will be displayed showing whether the number is odd or even.    ... number is even: If the entered number is odd: Download Source Code... JSP JSTL c:when tag   
Version of jstl>jstl dependency
List of Version of jstl>jstl dependency
jstl - Java Beginners
jstl   hi, I need sample code for auto increment the serial number fro mthe table using jstl. Please send the sample code urgently needed. Thanks, Valarmathi
AN INTRODUCTION TO JSTL
AN INTRODUCTION TO JSTL
Throwing an Exception in JSTL
Throwing an Exception in JSTL     ... what will happen if we try to divide any number by 0. After going through this example you can better understand how the exception can be thrown in JSTL.  
Artifacts of jstl
List of Artifacts of jstl maven depenency
Installing JSTL,Downloading JSTL, Installing JSTL
Installing JSTL Different installation procedure has to be followed for Tomcat 4.x and Tomcat 5.x Containers. To use JSTL two files jstl.jar and standart.jar... be copied from the examples folder webapps/jsp-examples/WEB-INF/lib/ folder. JSTL
Maven Dependency jstl >> 1.0
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0 in your project
Maven Dependency jstl >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.1 in your project
Maven Dependency jstl >> 1.0.2
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.2 in your project
Maven Dependency jstl >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.3 in your project
Maven Dependency jstl >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.4 in your project
Maven Dependency jstl >> 1.0.5
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.5 in your project
Maven Dependency jstl >> 1.0.6
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.0.6 in your project
Maven Dependency jstl >> 1.1.0
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.1.0 in your project
Maven Dependency jstl >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.1.1 in your project
Maven Dependency jstl >> 1.1.2
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.1.2 in your project
Maven Dependency jstl >> 1.2
You should include the dependency code given in this page to add Maven Dependency of jstl >> jstl version1.2 in your project
Error in using jstl tags
Error in using jstl tags  I'm trying to use jstl tags in jsp.i've.../jstl/core" %> but still i'm getting the error "CANNOT FIND THE TAG LIBRARY DESCRIPTOR FOR http://java.sun.com/jsp/jstl/core " Please tell me where am i
how to use jstl tags?
how to use jstl tags?  I installed jstl jar in my libraries. I got the following error in console screen. I need the solution to resolve this uri in web.xml. please help me.......... "The absolute cannot be resolved
jstl - JSP-Servlet
jstl  path to download a JWSDP1.3 software for jstl  Hi friend, Read for more information. http://www.roseindia.net/jstl/introduction.shtml
JSTL XML Tags
in this tutorial you will learn JSTL XML examples
JSTL in JSF2 Facelet makes sense?
JSTL in JSF2 Facelet makes sense?  JSTL in JSF2 Facelets makes sense
JSTL in Netbeans 6.9.1
JSTL in Netbeans 6.9.1  I am seeking your help in solving problem I... in my jsp. In order to use JSTL in my JSP I had written below code for pointing JSTL core tag <%@taglib prefix="c" uri="/WEB-INF/core-rt" %> I have placed
JSTL - JSP-Servlet
JSTL  i tried one example on jstl tag.i successfully imported content from other web app as i specified in url attribute.but i could not get the images in that web page.i had to copy those images and paste in my webapp/images
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
Introduction to the JSTL
Introduction to the JSTL       JSP Standard Tag Library or JSTL for short.... JSTL are the jsp tag libraries released by SUN to ease the JSP programming

Ads

 
Advertisement null

Ads