Implementing Conditional Content on a JSP Page - Java Servlet JSP

Java examples for Servlet JSP:JSP

Description

Implementing Conditional Content on a JSP Page

<% if ("someValue".equals(request.getParameter("param1"))) { %>
    Generate this template text if param1 equals someValue
<% } else { %>
    Otherwise generate this template text
<% } %>


<% switch (Integer.parseInt(request.getParameter("param2"))) {
    case 0: %>
       Generate this template text if param2 equals 0
<%     break;
    case 1: %>
       Generate this template text if param2 equals 1
<%     break;
    default: %>
       Generate this template text if param2 equals anything else
<% } %>

Related Tutorials