aspose file tools*
The moose likes JSP and the fly likes deletion problem.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "deletion problem.." Watch "deletion problem.." New topic
Author

deletion problem..

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
hi..first of all, great thanks..its a great site..to get solution for ur problems..

as usual stuck up again..
got a problem in deletion..
iam not able to select anything to delete the records...the deletion page is not able to get any data..

i have this browse.jsp page..which will show the records and against them a checkbox in each..to record the selected data.
browse code is like this:
<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;
boolean y=false;
int j;
int mcount=0;
String xy=(String)session.getAttribute("y");

String sRecordCount=(String)request.getParameter("RecordCount");
int iRecordCount=Integer.parseInt(sRecordCount);
Vector vRecords=(Vector)session.getAttribute("Records");
int iNo_Of_Records=vRecords.size();
%>
<form action="teaching_load_deleted.jsp" method="post" onSubmit="return confirm_me()">
<table border="1" cellpadding="1" cellspacing="1">
<td>
<div align="center"><i><em><font face="Arial, Helvetica, sans-serif">Semester</font></em></i></div>
</td>
<td>
<div align="center"><i><em><font face="Arial, Helvetica, sans-serif">Course</font></em></i></div>
</td>
<td>
<div align="center"><i><em><font face="Arial, Helvetica, sans-serif">Course
Number</font></em></i></div>
</td>
<td>
<div align="center"><i><em><font face="Arial, Helvetica, sans-serif">Course
Title</font></em></i></div>
</td>
</tr>
<tr>
<%
for(int i=(iRecordCount-5);i<iRecordCount;++i)
{
mcount++;
if(i>=iNo_Of_Records)
break;
teaching ob =(teaching)vRecords.elementAt(i);
%>
<td font="arial" > <%=ob.getSemester()%></td>
<td> <%=ob.getCourse()%></td>
<td> <%=ob.getCourse_No()%></td>
<td> <%=ob.getCourse_Title()%></td>
<td>
<input type="checkbox" name="var_load_id<%=mcount%>" value="<%=ob.getLoad_id()%>">
</td>
</tr>
<%
}

%>
</table>
</form>

<%
if(iRecordCount>5)
{
%>
<a
href='browse_teaching_load.jsp?RecordCount=<%=(iRecordCount-5)%>'>Previous</a>
<%
}
%>
<%
if(iRecordCount<iNo_Of_Records)
{
%>
<a
href='browse_teaching_load.jsp?RecordCount=<%=(iRecordCount+5)%>'>Next</a>
<%
}
%>
<a href="teaching_load_deleted.jsp">Delete</a> </div>

and my deletion.jsp page is like this:
<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;
String xy=(String)session.getAttribute("y");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();
String ids[]=request.getParameterValues("var_load_id<%=mcount%">");
<%
String selectedId="";
if(ids!=null)
{
if(ids.length == 1)
{
selectedId=ids[0];
System.out.println("load_id"+selectedId);
}
else
{
//multiple items selected
for(int i=0;i<ids.length;i++)
{
selectedId += ids[i];
if(i<ids.length-1)
{
selectedId += ",";
}
}

System.out.println("load_ids"+selectedId);
}
out.println("delete from teaching_load where load_id in("+selectedId+")");
String sql="delete from teaching_load where load_id in("+selectedId+")";
stmt.executeUpdate(sql);
con.commit();
stmt.close();
con.close();
System.out.println("has been deleted succesfully");
}
else
{
//nothing selected
out.println("<p>you have not selected anything to delete");
}

}

catch(Exception e)
{
System.out.println(e);
}
%>

can anyone figure this out.
thanks
Gert Cuppens
Ranch Hand

Joined: Jul 13, 2003
Posts: 87
If your deletion page is really called "deletion.jsp", then I can't see where you're calling this page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: deletion problem..