JSP Basics: Dynamic Page Creation for Data Presentation 2 : Basics « JSP « Java






JSP Basics: Dynamic Page Creation for Data Presentation 2

JSP Basics: Dynamic Page Creation for Data Presentation 2

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

*/



<html>
<head>
<link rel=stylesheet type="text/css" href="portal.css">
<title>Select Your Portal</title></head>
<body>
<table class="mainBox" width="400">
<tr><td class="boxTitle" colspan="2">
Wrox JSP Portal Selector
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td>
<form  action="showportal.jsp" method="get">
<table>
<tr>
<td width="200">Portal Selection</td><td>
<select name="portchoice">
<option>news</option>
<option>weather</option>
<option>entertainment</option>
</select>
</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="Select"/>
</td></tr>
</table>
</form>
</td></tr></table>
</body>
</html>

//showportal.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
 <c:choose>
    <c:when test="${param.portchoice == 'news'}">
      <jsp:include page="news.jsp" />
    </c:when>
    <c:when test="${param.portchoice == 'weather'}">
      <jsp:include page="weather.jsp" />
    </c:when>
    <c:when test="${param.portchoice == 'entertainment'}">
      <jsp:include page="entertain.jsp" />
    </c:when>
    <c:otherwise>
       <head><title>System Portal</title></head>
       <body>
       <h1>Application logic problem detected!</h1>   
    </c:otherwise>
</c:choose>
</body>
</html>


//news.jsp

<head>
<link rel=stylesheet type="text/css" href="portal.css">
<title>News Portal</title>
</head>
<body>
<table class="mainBox" width="600">
<tr><td class="boxTitle" >
Welcome to the News Portal!
</td></tr>
<tr><td> 
<span class="headLine">
<jsp:useBean id="newsfeed" class="com.wrox.begjsp.ch2.NewsFeed" scope="request" >
<jsp:setProperty name="newsfeed"  property="topic" value="news"/>
<jsp:getProperty name="newsfeed" property="value"/>
</jsp:useBean>
</span>
<span class="newsText">
<jsp:include page="dummytext.html" />
</span>
</td></tr>
</table>

           
       








BeginningJavaServerPages-ch02-2.zip( 292 k)

Related examples in the same category

1.JSP Passing Parameters
2.Simplest Jsp page: A Web Page
3.Output: Creating a Greeting
4.Simple JSP outputSimple JSP output
5.Simple JSP page to display the random number
6.Comments in JSP page
7.Declaration Tag Example
8.Declaration Tag - Methods
9.Expression Language Examples
10.Passing parameters
11.JSP Initialization
12.Welcome page and top level URL
13.JSP Expression Language
14.JSP without beans
15.Request header display in a JSP
16.Multiple Declaration
17.Embedding Code
18.pwd -- print working directory
19.JSP post
20.JSP Post Data Viewer
21.JSP in J2EE
22.JSP Performance
23.JSP Best Practices and Tools
24.JSP Model 2JSP Model 2
25.JSP: expression language 2JSP: expression language 2
26.JSP Directives: your page
27.JSP Directives
28.JSP Basics ch02 JSP Basics ch02
29.JSP Basics: Generalized Templating and Server Scripting 1JSP Basics: Generalized Templating and Server Scripting 1
30.JSP Basics: Generalized Templating and Server Scripting 2JSP Basics: Generalized Templating and Server Scripting 2
31.JSP Basics: Generalized Templating and Server Scripting 3JSP Basics: Generalized Templating and Server Scripting 3
32.CSS, JavaScript, VBScript, and JSP 1CSS, JavaScript, VBScript, and JSP 1
33.CSS, JavaScript, VBScript, and JSP 2CSS, JavaScript, VBScript, and JSP 2
34.Advanced Dynamic Web Content Generation. 1Advanced Dynamic Web Content Generation. 1