JSTL - check odd/even number



Share on Google+Share on Google+

JSTL - check odd/even number
1 Answer(s)      7 years ago
Posted in : JSP-Servlet
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);
int pno=num-1;
int nno=num+1;
<form method="post">Random Number:<input type="hidden" name="number" value="<%=num%>" />
<input type="submit" value="Accept" />
<c:if test="${pageContext.request.method=='POST'}">Random number is: <%=num%>
<c:when test="${param.number%2==0}">It is an even number lies between <%=pno%> and <%=nno%>.
<br />
<c:otherwise>It is an odd number lies between <%=pno%> and <%=nno%>.
<br />

For more information, visit the following link:



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
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   
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
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.  
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
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
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 <[email protected] 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
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
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
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
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
jstl if else
In this section we have discussed about how to implement if-else tag in JSTL...;> <form method="get">Enter a number from one onwards : <...;/c:if> </body> </html> Resource: JSTL
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
JSTL Tutorial Part 2
In this tutorial you will learn about some advance JSTL example of JSP
-Standard Tag Library (JSTL) project.  Though there are a number of popular... to learn JSTL, because, jstl library is not built into Tomcat5  even...AN   INTRODUCTION   TO   JSTL    
JSTL XML Tags Part 2
In this tutorial you will learn some more example about JSTL XML
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
Downloading JSTL
Downloading JSTL      ...) then follow the following steps to use JSTL in your program. Different installation procedure has to be followed for Tomcat 4.x and Tomcat 5.x Containers. To use JSTL
IF-ELSE In JSTL In this section we will read about implementation of if-else tag in JSTL. We will see the implementation of this tag using a simple example. In JSTL if-else tag is not implemented directly like the if-else statement
JSTL: Set Session Attribute
JSTL: Set Session Attribute     ... are using the jstl and there is a need to set a variable in the session. You all know that it can be done very easily in the servlets and jsp, but what about jstl
Overview of JSTL Tags
Overview of JSTL Tags       This section gives you an overview of JSTL tags. This section will introduce you with all the tags provided by the JSTL library. The JSTL 1.1 API