title: how to pass a database retrieved value to jsp
body: <p>I written a program to retrieve data from database in servlets.now I want pass this value to jsp as a hyperlink. How to do this?</p>
  
  <p>This is my servlet code what I wrote:</p>
  
  <pre><code>  import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
  
    public class ViewServlet extends HttpServlet{
    public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
    {
    res.setContentType("text/html");
    PrintWriter pw = res.getWriter();
    Connection con;
    Statement stmt;
    ResultSet rs;
    String acid = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:DSN","scott","krishna");
    stmt = con.createStatement();
    rs = stmt.executeQuery("Select id from custm where name='jai'");
    req.setAttribute(acid,rs);
    req.getRequestDispatcher("my_jsp_page.jsp").forward(req, res); 
     }
    catch (Exception e){
    pw.println(e);
    }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>Now I edited the code now its saying cannot call <code>setAttribute</code> with null value.</p>