Class 2 Intermediate Java 30-IT-397  

An Example


<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>

<%
String band = request.getParameter("group");

if (band == null) {
    out.println("Please enter your favorite disco band.");
} else {
    out.println(band  + ": ");

    if (band.equals("KC")) { %>
        Boogie Man
    <% } else if (band.equals("Sylvester")) { %>
        Do you want to funk
    <% } else if (band.equals("Brick")) { %>
        Dazz
    <% } else if (band.equals("Parliament")) { %>
        Brick House
    <% } else { %>
        What music do <i>you</i> listen to?
    <% }
}

%>

<form name="group" method="GET" action="http://10.78.1.95:8080/examples/jsp/Music.jsp">
Enter your favorite group:
<input type = "text" name = "group">
<br>
<input type="submit">
</form>
</body>
</html>
<> View the Output (Note: The screen shots are not from this example, but instead from a previous example, the fahrenheit:celcius converter.  The concept is similar to the disco JSP we're making here.)

Created by:  Brandan Jones December 17, 2001