#Real Time Search in a JSP

3 messages · Page 1 of 1 (latest)

molten moon
#

I have a JSP that shows a table of data retrieved from a derby database via servlets and I would like to use Spring to create a real time search bar that updates the table based on keypress. I would usually use JavaScript for this but our professor strictly told us to use MVC Framework using JSP and Servlets and Spring.

This is my code for the table container I would like to have a search bar with.
It uses jsp scriplets in order to retrieve data from the servlet context and uses said data to generate a bunch of table rows.

<div class="table-container">
        <input type="text" id="search">
        <table>
            <thead>
                <tr>
                    <th>Product ID</th>
                    <th>Product Name</th>
                    <th>Series</th>
                    <th>Price</th>
                </tr>   
            </thead>
            <%
                List<Product> products = (List<Product>) getServletContext().getAttribute("productList");
                for (Product product : products) {
            %>
            <tbody
                <tr>
            <td><%=product.getProductId()%></td>
            <td><%=product.getName()%></td>
            <td><%=product.getSeries().substring(0, 1).toUpperCase() + product.getSeries().substring(1)%></td>
            <td><%=product.getPrice()%></td>
            </tr>
            </tbody>
            <%
                }
            %>

        </table>
    </div>
crimson wrenBOT
#

This post has been reserved for your question.

Hey @molten moon! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.