- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a switch statement in a JSP page?
Following is the example of using a switch statement within a JSP page.
<%! int day = 3; %> <html> <head> <title>SWITCH...CASE Example</title> </head> <body> <% switch(day) { case 0: out.println("It\'s Sunday."); break; case 1: out.println("It\'s Monday."); break; case 2: out.println("It\'s Tuesday."); break; case 3: out.println("It\'s Wednesday."); break; case 4: out.println("It\'s Thursday."); break; case 5: out.println("It\'s Friday."); break; default: out.println("It's Saturday."); } %> </body> </html>
The above code will generate the following result −
It's Wednesday.
- Related Articles
- How to write an if-else statement in a JSP page?
- How to write a comment in a JSP page?
- How to write a for loop in a JSP page?
- How to write a while loop in a JSP page?
- Can we have a switch statement in JSP for XPath expression?
- How to create a common error page using JSP?
- How to refresh a JSP page at regular interval?
- How to write a JSP Expression?
- How to send a html based email using a JSP page?
- How to send a email with attachment using a JSP page?
- How to print current date and time in a JSP page?
- How to executes an SQL SELECT statement in a JSP?
- What is a page object in JSP?
- What is a page directive in JSP?
- How to define a switch statement in JShell in Java 9?

Advertisements