how to pass value from one jsp to another jsp page

how to pass value from one jsp to another jsp page  using -'java,jsp'

Hi i  have two jsp page   search.jsp,update.jsp.
when i run search.jsp then one value fetch from database and i store that value in a variable called scard now i want to use that variable value in another jsp page. i do not want to use request.getparameter()

here is my code

         String scard="";
         String id=request.getParameter("id");


String selectStoredProc = "SELECT * FROM Councel WHERE CouncelRegNo ='"+id+"'";

                        PreparedStatement ps = cn.prepareStatement(selectStoredProc);
                    ResultSet rs=ps.executeQuery();
                    while( {

                    rs = null;
                catch (Exception e) {
                finally {     


how can i achieve this?

Thanks in advance

asked Oct 19, 2015 by bhavin
0 votes

2 Answers

0 votes

Use sessions

On your search.jsp

Put your scard in sessions using session.setAttribute("scard","scard")

//the 1st variable is the string name that you will reteive in ur next page,and the 2nd variable is the its value,i.e the scard value.

And in your next page you retrieve it using session.getAttribute("scard")


answered Oct 19, 2015 by abhimca2006