Problem w/App based on E-Commerce Tutorial

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem w/App based on E-Commerce Tutorial

rexbroo

Hi All,

I'm developing a set of parallel reference implementations of several OASIS Emergency Data Exchange Language (EDXL) specifications based on the NetBeans E-Commerce Tutorial ( https://netbeans.org/kb/docs/javaee/ecommerce/intro.html ).

I'm having a problem going from the JSTL-based stage of development (Section 6. Connecting the Application to the Database) to the Entity Classes & Session Beans Persistence Unit-based stage.(Section 7. Adding Entity Classes and Session Beans).

edxl-cap-v1_2-refimp-Stage3_3-category.jsp  (Uses JSTL, works correctly)

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

<%--
    Document   : category
    Created on : May 29, 2017, 8:21:24 AM
    Author     : rexbrooks
--%>

<sql:query var="categories" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM category
</sql:query>
   
<sql:query var="selectedCategory" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM category WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element
</sql:query>
   
<sql:query var="selectedElement" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM element WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
       
<sql:query var="categoryElements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE category_id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

<sql:query var="elementDatatypes" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elementDatatypes" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype_size = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

        <div id="edxlLeftColumn">
            <c:forEach var="category" items="${categories.rows}">

                <c:choose>
                    <c:when test="${category.id == pageContext.request.queryString}">
                        <div class="edxlButton" id="selectedCategory">
                            <span class="edxlText">
                                ${category.name}
                            </span>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <a href="category?${category.id}" class="edxlButton">
                            <div class="edxlText">
                                ${category.name}
                            </div>
                        </a>
                    </c:otherwise>
                </c:choose>

            </c:forEach>
        </div>

            <div id="edxlRightColumn">
               
                <p id="edxlCategoryTitle">${selectedCategory.rows[0].name}</p>
               
                <p style="font-size:x-small;padding:2px;text-align:center">repeat button is for multiple-use elements. * = required</p>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                            name="categoryId"
                            value="${ReviewCategory.id}">
                    <input type="submit"
                            value="review category">
                </form>
              
                <table id="elementTable" class="smallText">
                   
                    <c:forEach var="element" items="${categoryElements.rows}" varStatus="iter">

                        <tr class="${((iter.index % 2) == 0) ? 'lightBlue' : 'white'}">
                            <td>
                                <input type="checkbox" name="start">start
                            </td>
                            <td>
                                &nbsp;&nbsp;element:<br>
                                &nbsp;&nbsp; ${element.name}
                                <c:choose>
                                    <c:when test="${element.required == 1}">
                                         *
                                    </c:when>
                                    <c:otherwise>&nbsp;&nbsp;
                                    </c:otherwise>
                                </c:choose>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <div id="elementInput">
                                   
                                <%--<c:forEach var="element" items="${elements.rows}">--%>
                                   
                                    <c:choose>
                                    <%--<c:when test="${element.datatype == ENUM}">
                                            <div class="edxlDropdownButton" id="selectedElement">
                                                //script to retrieve values from ENUM datatype of selectedElement
                                                ${ENUM(values) = select(options)}
                                                //to populate drop-down list
                                                <span class="smallText">
                                                    Select&nbsp; ${element.name}
                                                    <select name="selectedElement" id="element.id">
                                                        <option value=""></option>
                                                        <co:forEach items="${element}" var="value">
                                                           <option>${value}</option>
                                                        </co:forEach>
                                                        </>
                                                    </select>--%>
                                                       
                                        <c:when test="${element.name == 'status'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; status
                                                    <select name="status">
                                                        <option>Actual</option>
                                                        <option>Exercise</option>
                                                        <option>System</option>
                                                        <option>Test</option>
                                                        <option>Draft</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'msgType'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; msgType
                                                    <select name="msgType">
                                                        <option>Alert</option>
                                                        <option>Update</option>
                                                        <option>Cancel</option>
                                                        <option>Ack</option>
                                                        <option>Error</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'scope'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; scope
                                                    <select name="scope">
                                                        <option>Public</option>
                                                        <option>Restricted</option>
                                                        <option>Private</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'category'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; category
                                                    <select name="category">
                                                        <option>Geo</option>
                                                        <option>Met</option>
                                                        <option>Safety</option>
                                                        <option>Security</option>
                                                        <option>Rescue</option>
                                                        <option>Fire</option>
                                                        <option>Health</option>
                                                        <option>Env</option>
                                                        <option>Transport</option>
                                                        <option>Infra</option>
                                                        <option>CBRNE</option>
                                                        <option>Other</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'responseType'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; responseType
                                                    <select name="responseType">
                                                        <option>Shelter</option>
                                                        <option>Evacuate</option>
                                                        <option>Prepare</option>
                                                        <option>Execute</option>
                                                        <option>Avoid</option>
                                                        <option>Monitor</option>
                                                        <option>Assess</option>
                                                        <option>AllClear</option>
                                                        <option>None</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'urgency'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; urgency
                                                    <select name="urgency">
                                                        <option>Immediate</option>
                                                        <option>Expected</option>
                                                        <option>Future</option>
                                                        <option>Past</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'severity'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; severity
                                                    <select name="severity">
                                                        <option>Extreme</option>
                                                        <option>Severe</option>
                                                        <option>Moderate</option>
                                                        <option>Minor</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'certainty'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; certainty
                                                    <select name="certainty">
                                                        <option>Observed</option>
                                                        <option>Likely</option>
                                                        <option>Possible</option>
                                                        <option>Unlikely</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when test="${element.datatype_size < 49}">
                                                    <%--<div class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span class="smallText">Enter ${element.name} value
                                                            <input type="text" name="elementValue" value="" size="25" />
                                                        </span>
                                                <%--</div>--%>
                                                </c:when>
                                                <c:otherwise>
                                                <%--<div class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span class="smallText">Enter ${element.name} value
                                                            <textarea name="elementValue" rows="3" cols="25">
                                                            </textarea>
                                                        </span>
                                                <%--</div>--%>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>

                            <%--</c:forEach>--%>

                            </div>

                        </td>
                        <td>
                           
                        <%--<c:forEach var="element" items="${elements.rows}">--%>

                            <c:choose>
                                <c:when test="${element.repeatable == 1}">
                                    <input type="radio" name="repeatElement" value="" />&nbsp;repeat
                                </c:when>
                                <c:otherwise>&nbsp;&nbsp;
                                </c:otherwise>
                            </c:choose>

                        <%--</c:forEach>--%>
                        </td>
                        <td>
                            <form action="addElement" method="post">
                                <input type="hidden"
                                       name="elementId"
                                       value="${element.id}">
                                <input type="submit"
                                       value="add element">
                            </form>
                        </td>
                    </tr>
            <%--</c:choose>--%>
                       
            </c:forEach>
                       
            </table>
               
            <form action="reviewCategory" method="post">
                <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                <input type="submit"
                        value="review category">
            </form>
                   
        </div>


categry page with element rows displays corectly

edxl-cap-v1_2-refimp-Stage3_3-category1pg.png (The page displays correctly above)
Here's the Controller Servlet: edxl-cap-v1_2-refimp-Stage3_3-ControllerServlet.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author rexbrooks
 */
@WebServlet(name="ControllerServlet",
        loadOnStartup = 1,
        urlPatterns={"/category",
                     "/reviewMessage",
                     "/assembleDE-CAP",
                     "/approveDE-CAP",
                     "/addElement",
                     "/repeatElement",
                     "/confirmElement",
                     "/confirmCategory",
                     "/returnToCategory",
                     "/proceedToAssembleDE-CAP",
                     "/confirmDE",
                     "/confirmCAP",
                     "/proceedToApproveDE-CAP",
                     "/approveDE-CAPMessage",
                     "/chooseLanguage"})
public class ControllerServlet extends HttpServlet {

    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if category page is requested
        if (userPath.equals("/category")) {
            // TODO: Implement category request
           
        // if returnToCategory page is called
        } else if (userPath.equals("/returnToCategory")) {
            // TODO: Implement return to category page request

        // if reviewMessage page is requested
        } else if (userPath.equals("/reviewMessage")) {
            // TODO: Implement cart page request

            userPath = "/reviewMessage";

        // if assembleDE-CAP page is requested
        } else if (userPath.equals("/assembleDE-CAP")) {
            // TODO: Implement checkout page request
           
        // if proceedToAssembleDE-CAP page is requested
        } else if (userPath.equals("/proceedToAssembleDE-CAP")) {
            // TODO: Implement proceed to assemble DE-CAP page request
           
        // if approveDE-CAP page is requested
        } else if (userPath.equals("/approveDE-CAP")) {
            // TODO: Implement approve page request
           
        // if proceedToApproveDE-CAP page is requested
        } else if (userPath.equals("/proceedToApproveDE-CAP")) {
            // TODO: Implement proceed to approve DE-CAP page request

        // if user switches language
        } else if (userPath.equals("/chooseLanguage")) {
            // TODO: Implement language request

        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request, response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if addElement action is called
        if (userPath.equals("/addElement")) {
            // TODO: Implement add product to cart action

        // if repeatElement action is called
        } else if (userPath.equals("/repeatElement")) {
            // TODO: Implement repeat element action
           
        // if confirmElement action is called
        } else if (userPath.equals("/confirmElement")) {
            // TODO: Implement confirm element action
           
        // if confirmCategory action is called
        } else if (userPath.equals("/confirmCategory")) {
            // TODO: Implement return to confirm category action
           
        // if confirmDE action is called
        } else if (userPath.equals("/confirmDE")) {
            // TODO: Implement confirm DE action
           
        // if confirmCAP action is called
        } else if (userPath.equals("/confirmCAP")) {
            // TODO: Implement confirm CAP action
           
        // if approveDE-CAPMessage action is called
        } else if (userPath.equals("/approveDE-CAPMessage")) {
            // TODO: Implement approve DE-CAP message action

            userPath = "/approveDE-CAPMessage";
        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request, response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}


edxl-cap-v1_2-refimp-Stage3_5-category.jsp (Uses Entity Classes & Session Beans but doesn't work correctly-table rows don't display because the rows are not processed)

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

<%--
    Document   : category
    Created on : May 29, 2017, 8:21:24 AM
    Author     : rexbrooks
--%>

<%--<sql:query var="categories" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM category
</sql:query>
   
<sql:query var="selectedCategory" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM category WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element
</sql:query>
   
<sql:query var="selectedElement" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM element WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
       
<sql:query var="categoryElements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE category_id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

<sql:query var="elementDatatypes" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elementDatatypes" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype_size = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>--%>

        <div id="edxlLeftColumn">
            <c:forEach var="category" items="${categories}">

                <c:choose>
                    <c:when test="${category.id == pageContext.request.queryString}">
                        <div class="edxlButton" id="selectedCategory">
                            <span class="edxlText">
                                ${category.name}
                            </span>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <a href="category?${category.id}" class="edxlButton">
                            <div class="edxlText">
                                ${category.name}
                            </div>
                        </a>
                    </c:otherwise>
                </c:choose>

            </c:forEach>
        </div>

            <div id="edxlRightColumn">
               
                <p id="edxlCategoryTitle">${selectedCategory.name}</p>
               
                <p style="font-size:x-small;padding:2px;text-align:center">repeat button is for multiple-use elements. * = required</p>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                    <input type="submit"
                         value="review category">
                </form>
              
                <table id="elementTable" class="smallText">
                   
                    <c:forEach var="element" items="${categoryElements}" varStatus="iter">

                        <tr class="${((iter.index % 2) == 0) ? 'lightBlue' : 'white'}">
                            <td>
                                <input type="checkbox" name="start">start
                            </td>
                            <td>
                                &nbsp;&nbsp;element:<br>
                                &nbsp;&nbsp; ${element.name}
                                <c:choose>
                                    <c:when test="${element.required == 1}">
                                         *
                                    </c:when>
                                    <c:otherwise>&nbsp;&nbsp;
                                    </c:otherwise>
                                </c:choose>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <div id="elementInput">
                                   
                                <%--<c:forEach var="element" items="${elements}">--%>
                                   
                                    <c:choose>
                                    <%--<c:when test="${element.datatype == ENUM}">
                                            <div class="edxlDropdownButton" id="selectedElement">
                                                //script to retrieve values from ENUM datatype of selectedElement
                                                ${ENUM(values) = select(options)}
                                                //to populate drop-down list
                                                <span class="smallText">
                                                    Select&nbsp; ${element.name}
                                                    <select name="selectedElement" id="element.id">
                                                        <option value=""></option>
                                                        <co:forEach items="${element}" var="value">
                                                           <option>${value}</option>
                                                        </co:forEach>
                                                        </>
                                                    </select>--%>
                                                       
                                        <c:when test="${element.name == 'status'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; status
                                                    <select name="status">
                                                        <option>Actual</option>
                                                        <option>Exercise</option>
                                                        <option>System</option>
                                                        <option>Test</option>
                                                        <option>Draft</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'msgType'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; msgType
                                                    <select name="msgType">
                                                        <option>Alert</option>
                                                        <option>Update</option>
                                                        <option>Cancel</option>
                                                        <option>Ack</option>
                                                        <option>Error</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'scope'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; scope
                                                    <select name="scope">
                                                        <option>Public</option>
                                                        <option>Restricted</option>
                                                        <option>Private</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'category'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; category
                                                    <select name="category">
                                                        <option>Geo</option>
                                                        <option>Met</option>
                                                        <option>Safety</option>
                                                        <option>Security</option>
                                                        <option>Rescue</option>
                                                        <option>Fire</option>
                                                        <option>Health</option>
                                                        <option>Env</option>
                                                        <option>Transport</option>
                                                        <option>Infra</option>
                                                        <option>CBRNE</option>
                                                        <option>Other</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'responseType'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; responseType
                                                    <select name="responseType">
                                                        <option>Shelter</option>
                                                        <option>Evacuate</option>
                                                        <option>Prepare</option>
                                                        <option>Execute</option>
                                                        <option>Avoid</option>
                                                        <option>Monitor</option>
                                                        <option>Assess</option>
                                                        <option>AllClear</option>
                                                        <option>None</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'urgency'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; urgency
                                                    <select name="urgency">
                                                        <option>Immediate</option>
                                                        <option>Expected</option>
                                                        <option>Future</option>
                                                        <option>Past</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'severity'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; severity
                                                    <select name="severity">
                                                        <option>Extreme</option>
                                                        <option>Severe</option>
                                                        <option>Moderate</option>
                                                        <option>Minor</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name == 'certainty'}">
                                        <%--<div class="edxlDropDownButton" id="selectedElement">
                                                <span class="smallText">--%>
                                                    Select&nbsp; certainty
                                                    <select name="certainty">
                                                        <option>Observed</option>
                                                        <option>Likely</option>
                                                        <option>Possible</option>
                                                        <option>Unlikely</option>
                                                        <option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when test="${element.datatype_size < 49}">
                                                    <%--<div class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span class="smallText">Enter ${element.name} value
                                                            <input type="text" name="elementValue" value="" size="25" />
                                                        </span>
                                                <%--</div>--%>
                                                </c:when>
                                                <c:otherwise>
                                                <%--<div class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span class="smallText">Enter ${element.name} value
                                                            <textarea name="elementValue" rows="3" cols="25">
                                                            </textarea>
                                                        </span>
                                                <%--</div>--%>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>

                                <%--</c:forEach>--%>

                            </div>

                        </td>
                        <td>
                           
                        <%--<c:forEach var="element" items="${elements.rows}">--%>

                            <c:choose>
                                <c:when test="${element.repeatable == 1}">
                                    <input type="radio" name="repeatElement" value="" />&nbsp;repeat
                                </c:when>
                                <c:otherwise>&nbsp;&nbsp;
                                </c:otherwise>
                            </c:choose>

                        <%--</c:forEach>--%>
                        </td>
                        <td>
                            <form action="addElement" method="post">
                                <input type="hidden"
                                       name="elementId"
                                       value="${element.id}">
                                <input type="submit"
                                       value="add element">
                            </form>
                        </td>
                    </tr>
            <%--</c:choose>--%>
                       
            </c:forEach>
                       
            </table>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                    <input type="submit"
                         value="review category">
                </form>
                   
        </div>

category
      page doesn'r display rows of form

edxl-cap-v1_2-refimp-Stage3_5-category1pg.png (The contents of the table don't display and are not processed)
edxl-cap-v1_2-refimp-Stage3_5-ControllerServlet.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import entity.Category;
import entity.Element;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import session.CategoryFacade;

/**
 *
 * @author rexbrooks
 */
@WebServlet(name="ControllerServlet",
        loadOnStartup = 1,
        urlPatterns={"/category",
                     "/reviewMessage",
                     "/assembleDE-CAP",
                     "/approveDE-CAP",
                     "/addElement",
                     "/repeatElement",
                     "/confirmElement",
                     "/reviewCategory",
                     "/confirmCategory",
                     "/returnToCategory",
                     "/proceedToAssembleDE-CAP",
                     "/confirmDE",
                     "/confirmCAP",
                     "/proceedToApproveDE-CAP",
                     "/approveDE-CAPMessage",
                     "/chooseLanguage"})
public class ControllerServlet extends HttpServlet {
   
    @EJB
    private CategoryFacade categoryFacade;
   
    @Override
    public void init() throws ServletException {

        // store category list in servlet context
        getServletContext().setAttribute("categories", categoryFacade.findAll());
    }

    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();
        Category selectedCategory;
        Collection<Element> categoryElements;

        // if category page is requested
        if (userPath.equals("/category")) {
           
            // get categoryId from request
            String categoryId = request.getQueryString();

            if (categoryId != null) {
               
                // get selected category
                selectedCategory = categoryFacade.find(Integer.parseInt(categoryId));
               
                // place selected category in request scope
                request.setAttribute("selectedCategory", selectedCategory);
               
                // get all elements for selected category
                categoryElements = (Collection<Element>) selectedCategory.getElementCollection();
               
                // place category elements in request scope
                request.setAttribute("categoryElements", categoryElements);

            }
           
        // if returnToCategory page is called
        } else if (userPath.equals("/returnToCategory")) {
            // TODO: Implement return to category page request

        // if reviewMessage page is requested
        } else if (userPath.equals("/reviewMessage")) {
            // TODO: Implement cart page request

            userPath = "/reviewMessage";

        // if assembleDE-CAP page is requested
        } else if (userPath.equals("/assembleDE-CAP")) {
            // TODO: Implement checkout page request
           
        // if proceedToAssembleDE-CAP page is requested
        } else if (userPath.equals("/proceedToAssembleDE-CAP")) {
            // TODO: Implement proceed to assemble DE-CAP page request
           
        // if approveDE-CAP page is requested
        } else if (userPath.equals("/approveDE-CAP")) {
            // TODO: Implement approve page request
           
        // if proceedToApproveDE-CAP page is requested
        } else if (userPath.equals("/proceedToApproveDE-CAP")) {
            // TODO: Implement proceed to approve DE-CAP page request

        // if user switches language
        } else if (userPath.equals("/chooseLanguage")) {
            // TODO: Implement language request

        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request, response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if addElement action is called
        if (userPath.equals("/addElement")) {
            // TODO: Implement add product to cart action

        // if repeatElement action is called
        } else if (userPath.equals("/repeatElement")) {
            // TODO: Implement repeat element action
           
        // if confirmElement action is called
        } else if (userPath.equals("/confirmElement")) {
            // TODO: Implement confirm element action
           
        // if confirmCategory action is called
        } else if (userPath.equals("/confirmCategory")) {
            // TODO: Implement return to confirm category action
           
        // if confirmDE action is called
        } else if (userPath.equals("/confirmDE")) {
            // TODO: Implement confirm DE action
           
        // if confirmCAP action is called
        } else if (userPath.equals("/confirmCAP")) {
            // TODO: Implement confirm CAP action
           
        // if approveDE-CAPMessage action is called
        } else if (userPath.equals("/approveDE-CAPMessage")) {
            // TODO: Implement approve DE-CAP message action

            userPath = "/approveDE-CAPMessage";
        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request, response);
        } catch (Exception ex) {
        }
    }

}

Stage3_3 uses JSTL and works fine as the png screen shot shows the table correctly

Stage 3_5 commented out the JSTL, added entity classes and session beans per the tutorial and runs successfully except the table doesn't display any rows. I ran the debuggerand with a breakpoint just past the start of the table section at the line:
<c:forEach var="element" items="${categoryElements}" varStatus="iter">

and stepped into that line and saw that the program immediately dropped out at the line:
</c:forEach>

just before the end tag of the table.. Version 3_3 works fine and processes all lines. Version 3_5 jumps as noted, but i dn't know why.

Any help would be enormously appreciated.

Regards,
Rex

-- 
Rex Brooks
Starbourne Communications Design
Email: [hidden email]
GeoAddress:
1361 Addison St. Apt. A
Berkeley, CA 94702
Phone: 510-898-0670 

Virus-free. www.avast.com
Reply | Threaded
Open this post in threaded view
|

Re: Problem w/App based on E-Commerce Tutorial

rexbroo
I apologize for sending a message that was received as html. I didn't
send it that way. I'm going to reply to this message, too and I will
paste that message into this message box to see if it comes through the
way I originally intended.

Sorry,
Rex
Reply | Threaded
Open this post in threaded view
|

Re: Problem w/App based on E-Commerce Tutorial

rexbroo
In reply to this post by rexbroo
I'm pasting the original message into this reply

Hi All,

I'm developing a set of parallel reference implementations of several
OASIS Emergency Data Exchange Language (EDXL) specifications based on
the NetBeans E-Commerce Tutorial (
https://netbeans.org/kb/docs/javaee/ecommerce/intro.html ).

I'm having a problem going from the JSTL-based stage of development
(Section 6. Connecting the Application to the Database) to the Entity
Classes & Session Beans Persistence Unit-based stage.(Section 7. Adding
Entity Classes and Session Beans).

edxl-cap-v1_2-refimp-Stage3_3-category.jsp  (Uses JSTL, works
correctly)

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

<%--
    Document   : category
    Created on : May 29, 2017, 8:21:24 AM
    Author     : rexbrooks
--%>

<sql:query var="categories" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM category
</sql:query>
   
<sql:query var="selectedCategory"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM category WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element
</sql:query>
   
<sql:query var="selectedElement"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM element WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
       
<sql:query var="categoryElements"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE category_id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

<sql:query var="elementDatatypes"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elementDatatypes"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype_size = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

        <div id="edxlLeftColumn">
            <c:forEach var="category" items="${categories.rows}">

                <c:choose>
                    <c:when test="${category.id ==
pageContext.request.queryString}">
                        <div class="edxlButton" id="selectedCategory">
                            <span class="edxlText">
                                ${category.name}
                            </span>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <a href="category?${category.id}"
class="edxlButton">
                            <div class="edxlText">
                                ${category.name}
                            </div>
                        </a>
                    </c:otherwise>
                </c:choose>

            </c:forEach>
        </div>

            <div id="edxlRightColumn">
               
                <p
id="edxlCategoryTitle">${selectedCategory.rows[0].name}</p>
               
                <p
style="font-size:x-small;padding:2px;text-align:center">repeat button
is for multiple-use elements. * = required</p>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                            name="categoryId"
                            value="${ReviewCategory.id}">
                    <input type="submit"
                            value="review category">
                </form>
             
                <table id="elementTable" class="smallText">
                   
                    <c:forEach var="element"
items="${categoryElements.rows}" varStatus="iter">

                        <tr class="${((iter.index % 2) == 0) ?
'lightBlue' : 'white'}">
                            <td>
                                <input type="checkbox"
name="start">start
                            </td>
                            <td>
                                &nbsp;&nbsp;element:<br>
                                &nbsp;&nbsp; ${element.name}
                                <c:choose>
                                    <c:when test="${element.required ==
1}">
                                         *
                                    </c:when>
                                    <c:otherwise>&nbsp;&nbsp;
                                    </c:otherwise>
                                </c:choose>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <div id="elementInput">
                                   
                                <%--<c:forEach var="element"
items="${elements.rows}">--%>
                                   
                                    <c:choose>
                                    <%--<c:when
test="${element.datatype == ENUM}">
                                            <div
class="edxlDropdownButton" id="selectedElement">
                                                //script to retrieve
values from ENUM datatype of selectedElement
                                                ${ENUM(values) =
select(options)}
                                                //to populate drop-down
list
                                                <span
class="smallText">
                                                    Select&nbsp;
${element.name}
                                                    <select
name="selectedElement" id="element.id">
                                                        <option
value=""></option>
                                                        <co:forEach
items="${element}" var="value">
                                                         
<option>${value}</option>
                                                        </co:forEach>
                                                        </>
                                                    </select>--%>
                                                       
                                        <c:when test="${element.name ==
'status'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp; status
                                                    <select
name="status">
                                                       
<option>Actual</option>
                                                       
<option>Exercise</option>
                                                       
<option>System</option>
                                                       
<option>Test</option>
                                                       
<option>Draft</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'msgType'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
msgType
                                                    <select
name="msgType">
                                                       
<option>Alert</option>
                                                       
<option>Update</option>
                                                       
<option>Cancel</option>
                                                       
<option>Ack</option>
                                                       
<option>Error</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'scope'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp; scope
                                                    <select
name="scope">
                                                       
<option>Public</option>
                                                       
<option>Restricted</option>
                                                       
<option>Private</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'category'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
category
                                                    <select
name="category">
                                                       
<option>Geo</option>
                                                       
<option>Met</option>
                                                       
<option>Safety</option>
                                                       
<option>Security</option>
                                                       
<option>Rescue</option>
                                                       
<option>Fire</option>
                                                       
<option>Health</option>
                                                       
<option>Env</option>
                                                       
<option>Transport</option>
                                                       
<option>Infra</option>
                                                       
<option>CBRNE</option>
                                                       
<option>Other</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'responseType'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
responseType
                                                    <select
name="responseType">
                                                       
<option>Shelter</option>
                                                       
<option>Evacuate</option>
                                                       
<option>Prepare</option>
                                                       
<option>Execute</option>
                                                       
<option>Avoid</option>
                                                       
<option>Monitor</option>
                                                       
<option>Assess</option>
                                                       
<option>AllClear</option>
                                                       
<option>None</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'urgency'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
urgency
                                                    <select
name="urgency">
                                                       
<option>Immediate</option>
                                                       
<option>Expected</option>
                                                       
<option>Future</option>
                                                       
<option>Past</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'severity'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
severity
                                                    <select
name="severity">
                                                       
<option>Extreme</option>
                                                       
<option>Severe</option>
                                                       
<option>Moderate</option>
                                                       
<option>Minor</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'certainty'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
certainty
                                                    <select
name="certainty">
                                                       
<option>Observed</option>
                                                       
<option>Likely</option>
                                                       
<option>Possible</option>
                                                       
<option>Unlikely</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when
test="${element.datatype_size < 49}">
                                                    <%--<div
class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span
class="smallText">Enter ${element.name} value
                                                            <input
type="text" name="elementValue" value="" size="25" />
                                                        </span>
                                                <%--</div>--%>
                                                </c:when>
                                                <c:otherwise>
                                                <%--<div
class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span
class="smallText">Enter ${element.name} value
                                                            <textarea
name="elementValue" rows="3" cols="25">
                                                            </textarea>
                                                        </span>
                                                <%--</div>--%>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>

                            <%--</c:forEach>--%>

                            </div>

                        </td>
                        <td>
                           
                        <%--<c:forEach var="element"
items="${elements.rows}">--%>

                            <c:choose>
                                <c:when test="${element.repeatable ==
1}">
                                    <input type="radio"
name="repeatElement" value="" />&nbsp;repeat
                                </c:when>
                                <c:otherwise>&nbsp;&nbsp;
                                </c:otherwise>
                            </c:choose>

                        <%--</c:forEach>--%>
                        </td>
                        <td>
                            <form action="addElement" method="post">
                                <input type="hidden"
                                       name="elementId"
                                       value="${element.id}">
                                <input type="submit"
                                       value="add element">
                            </form>
                        </td>
                    </tr>
            <%--</c:choose>--%>
                       
            </c:forEach>
                       
            </table>
               
            <form action="reviewCategory" method="post">
                <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                <input type="submit"
                        value="review category">
            </form>
                   
        </div>


category page with element rows displays correctly

(The image didn't transfer with the rest of the clipboard)

edxl-cap-v1_2-refimp-Stage3_3-category1pg.png (The page displays
correctly)
Here's the Controller Servlet:
edxl-cap-v1_2-refimp-Stage3_3-ControllerServlet.java

/*
 * To change this license header, choose License Headers in Project
Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author rexbrooks
 */
@WebServlet(name="ControllerServlet",
        loadOnStartup = 1,
        urlPatterns={"/category",
                     "/reviewMessage",
                     "/assembleDE-CAP",
                     "/approveDE-CAP",
                     "/addElement",
                     "/repeatElement",
                     "/confirmElement",
                     "/confirmCategory",
                     "/returnToCategory",
                     "/proceedToAssembleDE-CAP",
                     "/confirmDE",
                     "/confirmCAP",
                     "/proceedToApproveDE-CAP",
                     "/approveDE-CAPMessage",
                     "/chooseLanguage"})
public class ControllerServlet extends HttpServlet {

    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if category page is requested
        if (userPath.equals("/category")) {
            // TODO: Implement category request
           
        // if returnToCategory page is called
        } else if (userPath.equals("/returnToCategory")) {
            // TODO: Implement return to category page request

        // if reviewMessage page is requested
        } else if (userPath.equals("/reviewMessage")) {
            // TODO: Implement cart page request

            userPath = "/reviewMessage";

        // if assembleDE-CAP page is requested
        } else if (userPath.equals("/assembleDE-CAP")) {
            // TODO: Implement checkout page request
           
        // if proceedToAssembleDE-CAP page is requested
        } else if (userPath.equals("/proceedToAssembleDE-CAP")) {
            // TODO: Implement proceed to assemble DE-CAP page request
           
        // if approveDE-CAP page is requested
        } else if (userPath.equals("/approveDE-CAP")) {
            // TODO: Implement approve page request
           
        // if proceedToApproveDE-CAP page is requested
        } else if (userPath.equals("/proceedToApproveDE-CAP")) {
            // TODO: Implement proceed to approve DE-CAP page request

        // if user switches language
        } else if (userPath.equals("/chooseLanguage")) {
            // TODO: Implement language request

        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request,
response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if addElement action is called
        if (userPath.equals("/addElement")) {
            // TODO: Implement add product to cart action

        // if repeatElement action is called
        } else if (userPath.equals("/repeatElement")) {
            // TODO: Implement repeat element action
           
        // if confirmElement action is called
        } else if (userPath.equals("/confirmElement")) {
            // TODO: Implement confirm element action
           
        // if confirmCategory action is called
        } else if (userPath.equals("/confirmCategory")) {
            // TODO: Implement return to confirm category action
           
        // if confirmDE action is called
        } else if (userPath.equals("/confirmDE")) {
            // TODO: Implement confirm DE action
           
        // if confirmCAP action is called
        } else if (userPath.equals("/confirmCAP")) {
            // TODO: Implement confirm CAP action
           
        // if approveDE-CAPMessage action is called
        } else if (userPath.equals("/approveDE-CAPMessage")) {
            // TODO: Implement approve DE-CAP message action

            userPath = "/approveDE-CAPMessage";
        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request,
response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}

edxl-cap-v1_2-refimp-Stage3_5-category.jsp (Uses Entity Classes &
Session Beans but doesn't work correctly-table rows don't display
because the rows are not processed)

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

<%--
    Document   : category
    Created on : May 29, 2017, 8:21:24 AM
    Author     : rexbrooks
--%>

<%--<sql:query var="categories" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM category
</sql:query>
   
<sql:query var="selectedCategory"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM category WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elements" dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element
</sql:query>
   
<sql:query var="selectedElement"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT name FROM element WHERE id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
       
<sql:query var="categoryElements"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE category_id = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>

<sql:query var="elementDatatypes"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>
   
<sql:query var="elementDatatypes"
dataSource="jdbc/edxl_cap_v1_2_refimp">
    SELECT * FROM element WHERE datatype_size = ?
    <sql:param value="${pageContext.request.queryString}"/>
</sql:query>--%>

        <div id="edxlLeftColumn">
            <c:forEach var="category" items="${categories}">

                <c:choose>
                    <c:when test="${category.id ==
pageContext.request.queryString}">
                        <div class="edxlButton" id="selectedCategory">
                            <span class="edxlText">
                                ${category.name}
                            </span>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <a href="category?${category.id}"
class="edxlButton">
                            <div class="edxlText">
                                ${category.name}
                            </div>
                        </a>
                    </c:otherwise>
                </c:choose>

            </c:forEach>
        </div>

            <div id="edxlRightColumn">
               
                <p id="edxlCategoryTitle">${selectedCategory.name}</p>
               
                <p
style="font-size:x-small;padding:2px;text-align:center">repeat button
is for multiple-use elements. * = required</p>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                    <input type="submit"
                         value="review category">
                </form>
             
                <table id="elementTable" class="smallText">
                   
                    <c:forEach var="element"
items="${categoryElements}" varStatus="iter">

                        <tr class="${((iter.index % 2) == 0) ?
'lightBlue' : 'white'}">
                            <td>
                                <input type="checkbox"
name="start">start
                            </td>
                            <td>
                                &nbsp;&nbsp;element:<br>
                                &nbsp;&nbsp; ${element.name}
                                <c:choose>
                                    <c:when test="${element.required ==
1}">
                                         *
                                    </c:when>
                                    <c:otherwise>&nbsp;&nbsp;
                                    </c:otherwise>
                                </c:choose>
                                &nbsp;&nbsp;
                            </td>
                            <td>
                                <div id="elementInput">
                                   
                                <%--<c:forEach var="element"
items="${elements}">--%>
                                   
                                    <c:choose>
                                    <%--<c:when
test="${element.datatype == ENUM}">
                                            <div
class="edxlDropdownButton" id="selectedElement">
                                                //script to retrieve
values from ENUM datatype of selectedElement
                                                ${ENUM(values) =
select(options)}
                                                //to populate drop-down
list
                                                <span
class="smallText">
                                                    Select&nbsp;
${element.name}
                                                    <select
name="selectedElement" id="element.id">
                                                        <option
value=""></option>
                                                        <co:forEach
items="${element}" var="value">
                                                         
<option>${value}</option>
                                                        </co:forEach>
                                                        </>
                                                    </select>--%>
                                                       
                                        <c:when test="${element.name ==
'status'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp; status
                                                    <select
name="status">
                                                       
<option>Actual</option>
                                                       
<option>Exercise</option>
                                                       
<option>System</option>
                                                       
<option>Test</option>
                                                       
<option>Draft</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'msgType'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
msgType
                                                    <select
name="msgType">
                                                       
<option>Alert</option>
                                                       
<option>Update</option>
                                                       
<option>Cancel</option>
                                                       
<option>Ack</option>
                                                       
<option>Error</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'scope'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp; scope
                                                    <select
name="scope">
                                                       
<option>Public</option>
                                                       
<option>Restricted</option>
                                                       
<option>Private</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'category'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
category
                                                    <select
name="category">
                                                       
<option>Geo</option>
                                                       
<option>Met</option>
                                                       
<option>Safety</option>
                                                       
<option>Security</option>
                                                       
<option>Rescue</option>
                                                       
<option>Fire</option>
                                                       
<option>Health</option>
                                                       
<option>Env</option>
                                                       
<option>Transport</option>
                                                       
<option>Infra</option>
                                                       
<option>CBRNE</option>
                                                       
<option>Other</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'responseType'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
responseType
                                                    <select
name="responseType">
                                                       
<option>Shelter</option>
                                                       
<option>Evacuate</option>
                                                       
<option>Prepare</option>
                                                       
<option>Execute</option>
                                                       
<option>Avoid</option>
                                                       
<option>Monitor</option>
                                                       
<option>Assess</option>
                                                       
<option>AllClear</option>
                                                       
<option>None</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'urgency'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
urgency
                                                    <select
name="urgency">
                                                       
<option>Immediate</option>
                                                       
<option>Expected</option>
                                                       
<option>Future</option>
                                                       
<option>Past</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'severity'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
severity
                                                    <select
name="severity">
                                                       
<option>Extreme</option>
                                                       
<option>Severe</option>
                                                       
<option>Moderate</option>
                                                       
<option>Minor</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:when test="${element.name ==
'certainty'}">
                                        <%--<div
class="edxlDropDownButton" id="selectedElement">
                                                <span
class="smallText">--%>
                                                    Select&nbsp;
certainty
                                                    <select
name="certainty">
                                                       
<option>Observed</option>
                                                       
<option>Likely</option>
                                                       
<option>Possible</option>
                                                       
<option>Unlikely</option>
                                                       
<option>Unknown</option>
                                                    </select>
                                            <%--</span>
                                            </div>--%>
                                        </c:when>
                                        <c:otherwise>
                                            <c:choose>
                                                <c:when
test="${element.datatype_size < 49}">
                                                    <%--<div
class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span
class="smallText">Enter ${element.name} value
                                                            <input
type="text" name="elementValue" value="" size="25" />
                                                        </span>
                                                <%--</div>--%>
                                                </c:when>
                                                <c:otherwise>
                                                <%--<div
class="edxlTextInputButton" id="selectedElement">--%>
                                                        <span
class="smallText">Enter ${element.name} value
                                                            <textarea
name="elementValue" rows="3" cols="25">
                                                            </textarea>
                                                        </span>
                                                <%--</div>--%>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:otherwise>
                                    </c:choose>

                                <%--</c:forEach>--%>

                            </div>

                        </td>
                        <td>
                           
                        <%--<c:forEach var="element"
items="${elements.rows}">--%>

                            <c:choose>
                                <c:when test="${element.repeatable ==
1}">
                                    <input type="radio"
name="repeatElement" value="" />&nbsp;repeat
                                </c:when>
                                <c:otherwise>&nbsp;&nbsp;
                                </c:otherwise>
                            </c:choose>

                        <%--</c:forEach>--%>
                        </td>
                        <td>
                            <form action="addElement" method="post">
                                <input type="hidden"
                                       name="elementId"
                                       value="${element.id}">
                                <input type="submit"
                                       value="add element">
                            </form>
                        </td>
                    </tr>
            <%--</c:choose>--%>
                       
            </c:forEach>
                       
            </table>
               
                <form action="reviewCategory" method="post">
                    <input type="hidden"
                        name="categoryId"
                        value="${category.id}">
                    <input type="submit"
                         value="review category">
                </form>
                   
        </div>
category page doesn't display rows of form

edxl-cap-v1_2-refimp-Stage3_5-category1pg.png (The contents of the
table don't display and are not processed)
edxl-cap-v1_2-refimp-Stage3_5-ControllerServlet.java

/*
 * To change this license header, choose License Headers in Project
Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import entity.Category;
import entity.Element;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import session.CategoryFacade;

/**
 *
 * @author rexbrooks
 */
@WebServlet(name="ControllerServlet",
        loadOnStartup = 1,
        urlPatterns={"/category",
                     "/reviewMessage",
                     "/assembleDE-CAP",
                     "/approveDE-CAP",
                     "/addElement",
                     "/repeatElement",
                     "/confirmElement",
                     "/reviewCategory",
                     "/confirmCategory",
                     "/returnToCategory",
                     "/proceedToAssembleDE-CAP",
                     "/confirmDE",
                     "/confirmCAP",
                     "/proceedToApproveDE-CAP",
                     "/approveDE-CAPMessage",
                     "/chooseLanguage"})
public class ControllerServlet extends HttpServlet {
   
    @EJB
    private CategoryFacade categoryFacade;
   
    @Override
    public void init() throws ServletException {

        // store category list in servlet context
        getServletContext().setAttribute("categories",
categoryFacade.findAll());
    }

    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();
        Category selectedCategory;
        Collection<Element> categoryElements;

        // if category page is requested
        if (userPath.equals("/category")) {
           
            // get categoryId from request
            String categoryId = request.getQueryString();

            if (categoryId != null) {
               
                // get selected category
                selectedCategory =
categoryFacade.find(Integer.parseInt(categoryId));
               
                // place selected category in request scope
                request.setAttribute("selectedCategory",
selectedCategory);
               
                // get all elements for selected category
                categoryElements = (Collection<Element>)
selectedCategory.getElementCollection();
               
                // place category elements in request scope
                request.setAttribute("categoryElements",
categoryElements);

            }
           
        // if returnToCategory page is called
        } else if (userPath.equals("/returnToCategory")) {
            // TODO: Implement return to category page request

        // if reviewMessage page is requested
        } else if (userPath.equals("/reviewMessage")) {
            // TODO: Implement cart page request

            userPath = "/reviewMessage";

        // if assembleDE-CAP page is requested
        } else if (userPath.equals("/assembleDE-CAP")) {
            // TODO: Implement checkout page request
           
        // if proceedToAssembleDE-CAP page is requested
        } else if (userPath.equals("/proceedToAssembleDE-CAP")) {
            // TODO: Implement proceed to assemble DE-CAP page request
           
        // if approveDE-CAP page is requested
        } else if (userPath.equals("/approveDE-CAP")) {
            // TODO: Implement approve page request
           
        // if proceedToApproveDE-CAP page is requested
        } else if (userPath.equals("/proceedToApproveDE-CAP")) {
            // TODO: Implement proceed to approve DE-CAP page request

        // if user switches language
        } else if (userPath.equals("/chooseLanguage")) {
            // TODO: Implement language request

        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request,
response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {

        String userPath = request.getServletPath();

        // if addElement action is called
        if (userPath.equals("/addElement")) {
            // TODO: Implement add product to cart action

        // if repeatElement action is called
        } else if (userPath.equals("/repeatElement")) {
            // TODO: Implement repeat element action
           
        // if confirmElement action is called
        } else if (userPath.equals("/confirmElement")) {
            // TODO: Implement confirm element action
           
        // if confirmCategory action is called
        } else if (userPath.equals("/confirmCategory")) {
            // TODO: Implement return to confirm category action
           
        // if confirmDE action is called
        } else if (userPath.equals("/confirmDE")) {
            // TODO: Implement confirm DE action
           
        // if confirmCAP action is called
        } else if (userPath.equals("/confirmCAP")) {
            // TODO: Implement confirm CAP action
           
        // if approveDE-CAPMessage action is called
        } else if (userPath.equals("/approveDE-CAPMessage")) {
            // TODO: Implement approve DE-CAP message action

            userPath = "/approveDE-CAPMessage";
        }

        // use RequestDispatcher to forward request internally
        String url = "/WEB-INF/view" + userPath + ".jsp";

        try {
            request.getRequestDispatcher(url).forward(request,
response);
        } catch (Exception ex) {
        }
    }

}

Stage3_3 uses JSTL and works fine and dispalys the table correctly

Stage 3_5 commented out the JSTL, added entity classes and session
beans per the tutorial and runs successfully except the table doesn't
display any rows.

I ran the debugger with a breakpoint just past the start of the table
section at the line:
<c:forEach var="element" items="${categoryElements}" varStatus="iter">

and stepped into that line and saw that the program immediately dropped
out at the line:
</c:forEach>

just before the end tag of the table.. Version 3_3 works fine and
processes all lines. Version 3_5 jumps as noted, but i don't know why.

Any help would be enormously appreciated.

Regards,
Rex

--
Rex Brooks
Starbourne Communications Design
Email: [hidden email]
GeoAddress:
1361 Addison St. Apt. A
Berkeley, CA 94702
Phone: 510-898-0670