Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet 7665-JSTL---check-odd JSTL - check odd/even number

Have Programming Question? Ask it here!
 
 
 


Ernie
JSTL - check odd/even number
1 Answer(s)      4 years and 10 months ago
Posted in : JSP-Servlet



Advertisement
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 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
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
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   
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.  
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
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
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 - 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
JSTL Tutorial Part 2
In this tutorial you will learn about some advance JSTL example of JSP
AN INTRODUCTION TO JSTL
-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
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
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
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
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
JSTL Tutorials and Online Training
JSTL Tutorials and Online Training       JSTL (JSP Standard Tag Library)  is very promising... without using scriptlets. This JSTL Online training at RoseIndia.Net will help
JSP Standard Tag Libraries (JSTL)
JSP Standard Tag Libraries (JSTL)       JSTL is developed under the Java Community Process, in the JSR-052 expert group. The purpose of JSTL is to work towards a common
Use of <fn:length(String)> Tag of JSTL
:length> Tag of JSTL. This tag returns the number of items in a collection, or the number of characters in a string. This takes Object type as arguments... Use of <fn:length(String)> Tag of JSTL  
buzz number
buzz number  buzz number
How to store values in a database using JSTL? - JSP-Servlet
in database using JSTL name number Position add...How to store values in a database using JSTL?  I want to store values in a database... How can i store in database? Here is my code... This wil
Insert option does not work in my jstl... - JDBC
Insert option does not work in my jstl...  I have problem with this jstl code... This will extract and displays details from xml... But i cant able...://www.roseindia.net/jstl/jstlxmltags.shtml
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
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
Armstrong number
Armstrong number  I want java program for Armstrong 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 c:if tag in jsp
JSTL c:if TAG IN JSP In this Section, we will discuss about how to use JSTL... of JSTL is very similar to "if" control statement of java. It also...;test" attribute of JSTL "c:if" tag ,have the condition block. EXAMPLE
Use of <x:if> tag of JSTL
Use of <x:if> tag of JSTL     ... of Xml tag library of Jstl. This tag is used for selection of statements.../jsp/jstl/xml" %> Attributes:  var  Defines
JSTL: forEach and status
JSTL: forEach and status     ... are using the jstl. Instead of using directive we can use the <c:set> tag of jstl.  In this program we are going to use the tag <c
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
Primary number
Primary number  write a program to find the 100th or nth primary number?   import java.util.*; class PrimeNumber{ public static void main(String a[]) { Scanner input=new Scanner(System.in
Primary number
Primary number  write a program to find the 100th or nth primary number?   import java.util.*; class PrimeNumber{ public static void main(String a[]) { Scanner input=new Scanner(System.in
number pyramid
number pyramid   how to get the code for the following : 1 123 12345 1234567   class Pyramid{ public static void main(String args[]){ for(int i=1;i<=7
Advertisements
 

 

 

DMCA.com