i am working on a project. i have database and it has 20 coloumns for each row. i display rows in form of table. in table i am retrieving data from database and displaying it.

         <%   While(special.next()){    %>

           <ul class="features">
                        <li><%= special.getString("company")%></li>
                        <li><%= special.getString("catagory")%></li>
                        <li><%= special.getString("place")%></li>
                        <li><%= special.getString("verified")%></li>
                        <li><%= special.getString("phone")%></li>
                        <li><%= special.getString("description")%></li>
                    </ul>
                    <div class="footer">
                      <a href="new.jsp">more details</a>
                    </div>
               <%     }        %>

when i click on 'more details' it should go to new.jsp where it can display more detials about that particular company. for that i need to send 'id' of that particular row to see more details of that particular row. how do i sent id of that particular row to new jsp where i can retrive full detials and display it in new.jsp page?? or am i doing it wrong? my main problem is when i click on 'more detials' all detials of that row should come go to next page how do i do it???

It is easy. What you need to do is this:
Use c tag lib for loops and if's.

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

Create a bean that will have all the data you are showing in table:

<jsp:useBean id="allData" class="beans.AllDataBean" scope="session"></jsp:useBean>

And when you want to show more details about specific row you will need link to new page and that link will send that id you want.

<a href="/Project/RedirectServlet?ifRow=${allData.id}">Show more details</a>

You can do it in page already but I love to use servlets.
In that RedirectServlet you just grab all data you want to show on next page.
Put that in session or request and just redirect to new page.

RequestDispatcher rd = getServletContext().getRequestDispatcher("/someFolder/newPage.jsp");
                rd.forward(request, response);

On that newPage.jsp you will have just form with input fields that will show that data.

<div>${dataSent.name}</div>
<div>${dataSent.username}</div>
<div>${dataSent.email}</div>

And that would be it.

You have a lot of examples on this link, check it out.

If you have any questions feel free to ask.
Kind regards, Mike.

thanks for the solution and i started working on bean. i executed few examples as well. when i try to send data from anvesh.jsp to new.jsp following error is comming up.
anvesh.jsp

<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>SELECT Operation</title>
</head>
<body>

<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
     url="jdbc:mysql://localhost:3306/anvesh"
     user="root"  password="root"/>

<sql:query dataSource="${snapshot}" var="result">
SELECT * from specialoff;
</sql:query>

<table border="1" width="100%">
<tr>
   <th>Emp ID</th>
   <th>First Name</th>
   <th>Last Name</th>
   <th>Age</th>
   <th>Age</th>
</tr>
<c:forEach var="row" items="${result.rows}">
  <jsp:useBean id="fulldetails" class="fulldetails.AllData" scope="session"></jsp:useBean>
<tr>
   <td><c:out value="${row.companyname}"/></td>
   <td><c:out value="${row.catagory}"/></td>
   <td><c:out value="${row.offer}"/></td>
   <td><c:out value="${row.fromandto}"/></td>
   <td><a href="new.jsp?id=${fulldetails.id}">Show more details</a></td>
 </tr>

</c:forEach>
</table>
</body>
</html>

bean is:

package fulldetails;
public class AllData {

    String companyname;
    String catagory;
    String offer;
    String fromandto;
    String limititation;
    String address;
    String description;
    String phonenumber;
    String verified;
    int id;

    public void setCompanyname(String value) {
        companyname = value;
    }    
    public void Catagory(String value) {
        catagory = value;
    }    
    public void setOffer(String value) {
        offer = value;
    }    
    public void setFromandto(String value) {
        fromandto = value;
    }    
    public void setLimititation(String value) {
        limititation = value;
    }    
    public void setAddress(String value) {
        address = value;
    }    
    public void setDescription(String value) {
        description = value;
    }    
    public void setVerified(String value) {
        verified = value;
    }    
    public void setId(int value) {
        id = value;
    }    
    public String getCompanyname() {
        return companyname;
    }    
    public String getCatagory() {
        return catagory;
    }    
    public String getOffer() {
        return offer;
    }    
    public String getFromandto() {
        return fromandto;
    }    
    public String getLimititation() {
        return limititation;
    }    
    public String getDescription() {
        return description;
    }    
    public String getPhonenumber() {
        return phonenumber;
    }    
    public String getVerified() {
        return verified;
    }    
    public int getId() {
        return id;
    }        
}

and the error is :

https://www.daniweb.com/web-development/jsp/threads/491753/pass-value-from-one-jsp-to-another#

i am sending it to new.jsp by the way. what should i do? where am i wrong?

Try to fix it using servlet as I metion in post before:

    <a href="/Project/RedirectServlet?ifRow=${allData.id}">Show more details</a>

/Project/ is project name then goes servlet RedirectServlet and then id.

Then just redirect to page you want using servlet code i put in post before.

For problem you ask it can be that your pages anvesh.jsp to new.jsp are not in same folder.
If you are trying to send it to new.jsp it will search for that page in that folder if it is in different then you need to put /Project/NewFolder/new.jsp

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.