-1

I Have JSP code like this. I fetch the Image and data of the product using `forach in one page:

<c:forEach var="product" items="${products}" >
<div class="col-md-3">
    <div class="panel-body">
        <div>
            <a href="description.html">
                <div class="thumbnail">
                    <img src="data:image/jpeg;base64,${product.base64EncodedImage}" alt="image">
                    <div class="caption" align="center">
                        <p>
                            <h4>${product.name}</h4>
                            <h5>cost:Rs ${product.price}/-</h5>
                        </p>
                    </div>
                </div>
            </a>
        </div>
    </div>
</div>

Image of fetched data

Jsp Page output

Now I have to get the data and image OF PARTICULAR PRODUCT when I click on a tumbnail. I have to get the data in the servlet class and have to print the output in another page:

This is what I expect to see when I click on a thumbnail:

ON THIS PAGE I HAVE TO GET THE DATA WHEN WE HAVE TO CLICK ON TUMBNAIL

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

Pass product details to servlet using URL parameters:

<img src="data:image/jpeg;base64,${product.base64EncodedImage}" alt="image" href="<your-servlet>?productId=${product.productId}">

Retrieve the same in your Product detail servlet class and read the same,passing on the details to the respective page

request.getParameter("productId")
Shivam Aggarwal
  • 795
  • 1
  • 11
  • 30