JavaServer Pages 2.0

by Aaron E. Walsh





Listing One



<jsp:useBean id="web3Dlogo" scope="application" class="web3Dweb.Logo"/>

<img src    = "${web3Dlogo.URL}"

     height = "${web3Dlogo.high}"

     width  = "${web3Dlogo.wide}"/>





Listing Two



<img src="http://web3dweb.com/images/web3Dweb_banner_75dpi.png"

     width="780" height="239" />





Listing Three



<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>

<%@ page import="web3Dweb.MediaCategories" %>

<%@ page contentType="text/html; charset=ISO-8859-5" %>

<html>

 <head>

  <title>Web3D Web Media Submission Form : JSP SCRIPTLET VERSION</title>

  <meta name="Author" content="Milena Mejia, Dean Hantzis,

                               Ian Lamont, Aaron Walsh">

  <meta name="Copyright" content="Web3DWeb.com">

  <meta name="License" content="http://Web3DWeb.com/license">

  <link href="style.css" rel="stylesheet" type="text/css">

  <script src="validate.js" language="JavaScript"

          type="text/javascript"></script>

 </head>

 <body>

  <h1>.: Web3D Web :.</h1>

  <h2>.: Media Submission Form :.</h2>

  <form name="submitForm" onsubmit="return validateForm(this)"

        method="post"     action="confirmSubmission.jsp">

  <table width="340" cellpadding="5" cellspacing="0"

         border="0" align="center" summary="Submission form">

   <tbody>

    <tr><td colspan="3">

     <strong>Title:</strong>

      <img alt="Required Field" name="titleerror"

           src="blank.gif" width="118" height="10" border="0"><br>

      <input name="title" type="text" size="55"

             maxlength="255" value="">

     </td> </tr>

    <tr><td colspan="3">

     <br>

     <strong>Creator:</strong>

       <img alt="Required Field" name="creatorerror"

            src="blank.gif" width="118" height="10" border="0"><br>

       <input name="creator" type="text" size="55"

              maxlength="255" value="">

    </td></tr>

    <tr><td colspan="3">

     <br>

     <strong>URL:</strong>

     <img alt="Required Field" name="urlerror"

          src="blank.gif" width="118" height="10" border="0"><br>

     <input type="text" size="55" maxlength="255"

            name="url" value="http://">

    </td></tr>

    <tr><td colspan="3" height="5"> </td></tr>

    <tr><td colspan="3" align="center">

      <strong>Category:</strong>

       <select name="category">

         <option value="0" selected="selected">????</option>

            <jsp:useBean id="categories" scope="application"

                         class="web3Dweb.MediaCategories"/>

            <c:forEach var="item" items="${categories.mediaCategories}">

              <option><c:out value="${item}" /></option>

            </c:forEach>

       </select>

     <img alt="Required Field" name="categoryerror"

          src="blank.gif" width="118" height="10" border="0">

    </td></tr>

    <tr> <td colspan="3" height="5"> </td> </tr>

    <tr> <td colspan="3">

     <strong>Brief Description:</strong>

      <img alt="Required Field" name="summaryerror"

           src="blank.gif" width="118" height="10" border="0"><br>

      <textarea name="summary" cols="42" rows="8"></textarea>

    </td> </tr>

    <tr> <td colspan="3" height="5"> </td> </tr>

    <tr> <td colspan="3" align="center">

    <input type="submit" name="submitform" value="Submit">

    </td> </tr>

   </tbody>

  </table>

 </form>

</body>

</html>





Listing Four



<select name="category">

 <option value="0" selected="selected">????</option>

  <jsp:useBean id="categories"

               scope="application" class="web3Dweb.MediaCategories"/>

  <c:forEach var="item" items="${categories.mediaCategories}">

    <option><c:out value="${item}" /></option>

  </c:forEach>

</select>





Listing Five



package web3Dweb;

import java.util.*;

/**

 * Web3D Web Media Categories testing JavaBean. Note that in production media

 * categories are actually pulled live from a database.

 * @author Aaron E. Walsh

 * Copyright 2003, Web3D Web. All Rights Reserved.

 * Use subject to license terms: http://web3Dweb.com/license

 */

public class MediaCategories {

   private ArrayList mediaCategories;

   public MediaCategories() {

      mediaCategories = new ArrayList();

      mediaCategories.add("Movies");

      mediaCategories.add("Music");

      mediaCategories.add("Games");

      mediaCategories.add("Fun");

      mediaCategories.add("Shopping");

      mediaCategories.add("Sports");

      mediaCategories.add("Videos");

      mediaCategories.add("Worlds");

      Collections.sort(mediaCategories);

      mediaCategories.add("Misc.");

   }

   public Collection getMediaCategories() {

      return mediaCategories;

   }

}





Listing Six



<select name="category">

 <option value="0" selected="selected">????</option>

 <option>Fun</option>

 <option>Games</option>

 <option>Movies</option>

 <option>Music</option>

 <option>Shopping</option>

 <option>Sports</option>

 <option>Videos</option>

 <option>Worlds</option>

 <option>Misc.</option>

</select>





Listing Seven



<select name="category">

 <option value="0" selected="selected">????</option>

 <jsp:useBean id="categories"

              scope="application" class="web3Dweb.MediaCategories"/>

 <%

   Iterator i = categories.getMediaCategories().iterator();

   while (i.hasNext()) {

     String cat = (String)i.next();

 %>

   <option><%=cat%></option>

 <%

    }

 %>

</select>





Listing Eight



/**

 * Media.java. JSP 2.0 Simple Tag Handler for the Web3D Web "media" tag

 * @author Aaron E. Walsh

 * Copyright 2003, Web3D Web. All Rights Reserved.

 * Use subject to license terms: http://web3Dweb.com/license

 */

package web3Dweb;

import javax.servlet.jsp.JspException;

import javax.servlet.jsp.tagext.SimpleTagSupport;

import java.io.IOException;



/* Dymamically constructs the appropriate HTML tag(s) for the

 * media specified by the Web3D Web "media" tag

 */

public class Media extends SimpleTagSupport {

  private String name, category, width, height;

  // tag attribute setter methods

  public void setName(String name) {this.name=name;}

  public void setCategory(String category) {this.category=category;}

  public void setWidth(String width) {this.width=width;}

  public void setHeight(String height) {this.height=height;}

  // tag handler doTag() method

  public void doTag() throws JspException, IOException {

    MediaResolver mr = new MediaResolver(name, category);

    getJspContext().getOut().write(

     "<object" +

     " data=\"" + mr.getURL() + "\"" +

     " type=\"" + mr.getMimeType() + "\"" +

     " width=\"" + width + "\"" +

     " height=\"" + height + "\"" +

     ">" +

     mr.getParameters() +

     "</object>"

    );

  }

}





Listing Nine



(a)

<web3Dweb:media name="seaside" category="world"

                width="800" height="600"/>



(b)

<%@ taglib prefix="web3Dweb" uri="/WEB-INF/tlds/web3Dweb.tld" %>



(c)

<object data="http://web3dchat.com/seaside/wrl.wrl" type="model/vrml"

        width="800" height="600">

 <param name="src" value="http://web3dchat.com/seaside/wrl.wrl">

</object>



(d)

<web3Dweb:media name="valentine card" category="movie"

                width="800" height="600"/>





Listing Ten



<%@ taglib prefix="web3Dweb" uri="/WEB-INF/tlds/web3Dweb.tld" %>

<html>

  <head>

    <title>Web3D Web : Web3DWeb.com</title>

    <link href="style.css" rel="stylesheet" type="text/css">

    <meta name="Author" content="Aaron E. Walsh">

    <meta name="Copyright" content="Web3DWeb.com">

    <meta name="License" content="http://Web3DWeb.com/license">

  </head>

  <body bgcolor="white">

   <h1 align="center">IMMERSIVE WORLDS @ web3Dweb.com</h1>

   <h2>Your immersive 3D experience begins in a rustic seaside cabin.

   Open the red doors and walk down to the sea, jump into the wooden boat,

   dive into the water, and touch floating portals to enter new worlds...</h2>

   <web3Dweb:media name="seaside" category="world" width="800" height="600"/>

  </body>

</html>





