JSP: passing parameter and form : Form « JSP « Java






JSP: passing parameter and form

JSP: passing parameter and form
/*
Beginning JavaServer Pages
Vivek Chopra, Jon Eaves, Rupert Jones, Sing Li, John T. Bell
ISBN: 0-7645-7485-X

*/


<html>
<head><title>Select Your Portal</title></head>
<body>
<h1>Select your preferred portal:</h1>
<form action="showportal.jsp" method="get">
<select name="portchoice">
<option>news</option>
<option>weather</option>
<option>entertainment</option>
</select>
<input type="submit" value="Select"/>
</form>
</body>
</html>

//showportal.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
 <c:choose>
    <c:when test="${param.portchoice == 'news'}">
      <head><title>News Portal</title></head>
      <body>
       <h1>Welcome to the News Portal!</h1>   
      </body>
    </c:when>
    <c:when test="${param.portchoice == 'weather'}">
       <head><title>Weather Portal</title></head>
       <body>
        <h1>You Get the Latest Weather!</h1>   
       </body>
    </c:when>
    <c:when test="${param.portchoice == 'entertainment'}">
       <head><title>Entertainment Portal</title></head>
       <body>
       <h1>Entertainment News Just for You!</h1>   
       </body>
    </c:when>
    <c:otherwise>
       <head><title>System Portal</title></head>
       <body>
       <h1>Application logic problem detected!</h1>   
       </body>
    </c:otherwise>
</c:choose>
</html>
           
       








BeginningJavaServerPages-ch02-1.zip( 289 k)

Related examples in the same category

1.Retrieve Form Data Save To Bean And Output Jsp
2.Save Form Value To File Jsp
3.Name Guess Jsp
4.Using Multiple Forms
5.JSP form parameters with default values
6.JSP form and Java beans
7.JSP Standard Actions: retrieve information and formJSP Standard Actions: retrieve information and form