title: How to use request.setAttribute() to set and pass value by clicking on a link
body: <p>I want to pass value of a rowNo from one jsp file to another jsp file(to display image on that row) by using request.setAttribute() and request.getAttribute() whenever user clicks on a link.</p>
  
  <p>But when I try to use request.getAttribute() on second jsp page it gives following exception:
  org.apache.jasper.JasperException: java.lang.NumberFormatException: null</p>
  
  <p>On Index.jsp page I have :</p>
  
  <pre><code>&lt;%!
   int temp = 1;
  
   %&gt;
  
  &lt;a href="single.jsp" onclick="&lt;%= request.setAttribute("val", temp) %&gt;" &gt; 
  &lt;i class="glyphicon glyphicon-menu-right icon"&gt;&lt;/i&gt; &lt;/a&gt;
  </code></pre>
  
  <p>And on single.jsp page :</p>
  
  <pre><code>&lt;%
  
  dbConnect con = new dbConnect(); 
  ResultSet r = con.getConnection().executeQuery("select * from tblpic "); 
  
  String tp = (String) (request.getAttribute("val"));
  
  int i = Integer.parseInt(tp);
  
  r.absolute(i);
  
  %&gt;
  
  &lt;div class="thumb-image"&gt; &lt;img src="&lt;%= r.getString(2) %&gt;" data-imagezoom="true" class="img-responsive"&gt; &lt;/div&gt;
  </code></pre>
  
  <p>r.absolute(i) is used to move to that specific row in table.</p>
  
  <p>I have added this file on both jsp pages(I don't know it is necessary or not)    &lt;%@page import = "javax.servlet.http.HttpServletRequest"%></p>
  
  <p>I am working on net beans and struts framework. </p>