How to write a switch statement in a JSP page?

JSPJava 8Object Oriented ProgrammingProgramming

Following is the example of using a switch statement within a JSP page.

 Live Demo

<%! int day = 3; %>
      <title>SWITCH...CASE Example</title>
         switch(day) {
            case 0:
               out.println("It\'s Sunday.");
            case 1:
               out.println("It\'s Monday.");
            case 2:
               out.println("It\'s Tuesday.");
            case 3:
               out.println("It\'s Wednesday.");
            case 4:
               out.println("It\'s Thursday.");
            case 5:
               out.println("It\'s Friday.");
               out.println("It's Saturday.");

The above code will generate the following result −

It's Wednesday.
Published on 20-Mar-2019 12:08:17