I am new at JSP development. I have a code to pass value from one.jsp to second.jsp file. But it's not working for me. Please help me.
one.jsp
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:myDSN");
st= con.createStatement();
rs= st.executeQuery("select id,dr_name,categoryname,cityname,availability from doc_registration");
while(rs.next())
{
doc_id = rs.getInt("id");
doc_name=rs.getString("dr_name");
cat_name=rs.getString("categoryname");
city_name=rs.getString("cityname");
status=rs.getString("availability");
//request.setAttribute("Send",doc_id);
session.setAttribute("Send", doc_id);
out.println("<tr>");
out.println("<td>" + doc_id + "</td>");
out.println("<td>" + doc_name + "</td>");
out.println("<td>" + cat_name + "</td>");
out.println("<td>" + city_name + "</td>");
out.println("<td>" + status + "</td>");
out.println("<td> <a href ='update.jsp'><input type='button' value='Update' id='act' onclick=''/></a><a href ='delete.jsp'><input type='button' value='delete' id='deact' onclick=''/></a>");
out.println("</td>");
}
st.close();
con.close();
}
catch(Exception e)
{
out.println(e);
}
second.jsp
try
{
//int did = Integer.parseInt(request.getParameter("doc_id"));
int doc_id = (Integer)session.getAttribute("Send");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con2 =DriverManager.getConnection("jdbc:odbc:myDSN");
st2 =con2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
count= st2.executeUpdate("Delete from doc_registration Where id =" + doc_id);
if(count > 0)
{
out.println("<body bgcolor='#ECE5B6'>");
out.println(count + "Record(s) delete successfully");
out.println("<a href ='doc_availability.jsp'><input type='button' value='back' id='back' onclick=''/>");
}
else
{
out.println("id does not exit");
}
st2.close();
con2.close();
}
catch(Exception e)
{
out.println("Exception = " + e);
}
- In one jsp page i get the data from the doc_availability table and print in table format. and also add update & delete button. if delete button click then second.jsp page call.
- In second .jsp page is call but selected row is not deleted.i m trying to fetch data from one.jsp but its not working.
- I m trying get parameter,session attribute or location attribute but its all are not working.
Thank You For Help.