JSTL - check odd/even number

JSTL - check odd/even number

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









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
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
Version of jstl>jstl dependency
List of Version of jstl>jstl dependency
JSP JSTL c:when tag
, a message will be displayed showing whether the number is odd or even.  ADS... will be displayed as: ADS_TO_REPLACE_3 If the entered number is even: If the entered number is odd:ADS_TO_REPLACE_4 Download Source Code
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 Repository/Dependency: jstl | jstl
Maven Repository/Dependency of Group ID jstl and Artifact ID jstl. Latest version of jstl:jstl dependencies. # Version Release Date 1 1.0.1 22 Nov 2005
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 XML Tags
in this tutorial you will learn JSTL XML examples
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 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
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
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
buzz number
buzz number  buzz number
JSTL Training
JSTL Training       JSTL (JSP Standard Tag Library) allows the web developer to create powerful web application without using scriptlets. This JSTL training at RoseIndia.Net
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
jstl if else
In this section we have discussed about how to implement if-else tag in JSTL... a number from one onwards : <input type="text" name="number"...; Resource:ADS_TO_REPLACE_3 JSTL If- Else IF-ELSE In JSTL
connection with mysql with jstl - JSP-Servlet
connection with mysql with jstl  hi, i m working on jstl . i hv done connection in MS -Access with JSTL . The code is working well. but when i am... on JSTL with database: http://www.roseindia.net/jstl/executeQuery
JSTL- xml tag library - XML
JSTL- xml tag library  i was trying to try jstl-xml tags examples that were given on your site on the following url "http://www.roseindia.net/jstl.... exception javax.servlet.ServletException: java.io.FileNotFoundException: /jstl_xml
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
JSTL Tutorial Part 2
In this tutorial you will learn about some advance JSTL example of JSP
prime number
prime number  could u pls help me out in finding whether a number is a prime number or not?   import java.util.*; class CheckPrimeNumber { static boolean isPrime(int number){ boolean isPrime=false
PROBLEM IN ACCESSING JSTL - JSP-Servlet
PROBLEM IN ACCESSING JSTL   hii i m vikram ... i am using jsp application with tomcat 4.1 .and i want to use JSTL in my jsp page ...so how can i use JSTL in my page .. and i install jakaerta-taglibs-standard-1.1.2 in directory
Armstrong number
Armstrong number  I want java program for Armstrong number
prime number
prime number  write a java program for prime number
prime number
prime number  HI!I want a java program that accepts a number from user and displays whether it is a prime number or not using BufferedReader
Count number of "*"
Count number of "*"  I have this code to count the number of * from a string entered. but I need to find it from an text file. Any idea? import...++; } } System.out.println("The number of vowels in the given sentence
JSTL XML Tags Part 2
In this tutorial you will learn some more example about JSTL XML
JSTL XML Tags
in JSTL , make XML processing and even Transformation , a cynch! And ,we now proceed to study them. Making our study even easier, many of the xml tags in JSTL...JSTL XML Tags No one can have any second opinion about the elegance of xml
Number Pyramid
Number Pyramid  Hi Everyone, Can someone help me write the code for the following number pyramid: print... 0 0 0 0 4 ... "); There is 5 spaces in between each number
Downloading JSTL
Downloading JSTL      ...) then follow the following steps to use JSTL in your program.ADS_TO_REPLACE_1 Different... Containers. To use JSTL two files jstl.jar and standart.jar are required to be placed
Nested <c:forEach> in JSTL
Nested <c:forEach> in JSTL   ... (JSTL) core library, provides custom tags for basic functionality. Instead of using... the program. Here comes the use of the JSTL, which allows you to program

Ads