1

I've a requirement, where I fetch data from table, display the info on jsp. On the first jsp, I should display only basic info and provide a link (against each row) to other jsp where complete info of that particular record is displayed. So, when I query the database, I have the complete info and it is returned to jsp. Now, how can I avail this info to next jsp.

Below is the piece of code where I iterate over the result set..

<c:forEach var="result" items="${resultSetModel}">
    <tr>
            <td>${result.id}</td>
            <td>${result.name}</td>
            <td>${result.code}</td>
            <td>${result.status}</td>
            <td>${result.date}</td>
    </tr>

I want to pass the result object from my current jsp to next jsp.

I wanted something like this.. where ${result} be a link or something that pops up or redirect to another page with full details of the object.

<table id="transResults" class="table table-striped table-bordered">
        <thead>
            <tr>
                <th>Id</th>
                <th>Name</th>
                <th>Code</th>
                <th>Status</th>
                <th>Post date</th>
                <th>Details</th>
            </tr>
        </thead>

        <c:if test="${not empty resultSetModel}">

        <c:forEach var="result" items="${resultSetModel}">
         <tr>
            <td>${result.id}</td>
            <td>${result.name}</td>
            <td>${result.code}</td>
            <td>${result.status}</td>
            <td>${result.date}</td>
            <td>${result}</td>
         </tr>
        </c:forEach>   
        </c:if>
    </table>

Please let me know, if this is possible in jsp without storing the data in session.

  • Possible duplicate of https://stackoverflow.com/questions/22369717/how-to-pass-value-from-one-jsp-to-another-jsp-page – Pankaj Gadge Nov 30 '17 at 22:01
  • the only way that I can think of is by passing the data back in a post and then reloading it on the next page. it would be easier just to do another query I think though – John Kane Nov 30 '17 at 22:02

1 Answers1

0

One way you can achieve using jsp bean. Create a java class that represents your table. Initialize them and on click set properties and pass reference as session object. The jsp bean with session scope can be used in another jsp file and using get property you can retrieve all values of that object for display.

Thiyag
  • 11
  • 1