Search code examples
jspsetattributegetattribute

how to store the values of request parameter in jsp for next page


i have read in this forum itself when we use request.setAttribute and request.getAttribute

its value is only retained untill the jsp page is loaded. so they suggestted to use a hidden form and when i am ussing that hidden form - i cannot seem to get it right. it says that it is not permitted for void values of which i make sure that all the values being stored through .setAttribute have some initialized values.

here is the code where error showed

     **org.apache.jasper.JasperException: Unable to compile class for JSP: 

     An error occurred at line: 83 in the jsp file: /season1.jsp
     The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
     80:   <!-- end .content --></div>
     81:   </form>
     82:   <%i=1;%>
     83:   <input type="hidden" name="epnostorage" value="<%= request.setAttribute("epno", epno) %>" />
     84:   <input type="hidden" name="casestorage" value="<%= request.setAttribute("case", i) %>" />
     85:   <%
     86:   }


     An error occurred at line: 84 in the jsp file: /season1.jsp
     The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
     81:   </form>
     82:   <%i=1;%>
     83:   <input type="hidden" name="epnostorage" value="<%= request.setAttribute("epno", epno) %>" />
     84:   <input type="hidden" name="casestorage" value="<%= request.setAttribute("case", i) %>" />
     85:   <%
     86:   }
     87: else if(i==1)


     **

Solution

  • session is one way to store the value

    session.setAttribute("name",value);