java.lang.ArrayIndexOutOfBoundsException: 3 after sendRedirect(Home.jsp);
hey guys,
im a student, fairly new to to JSP and have been having serious problems with the following and would very much be grateful if anyone could possibly lend me a hand:
I am creating a car sharing website for my dissertation, at the moment I am trying to create the logic to delete a journey from a users account. When the user logs in their journies are displayed on the homepage, below is an extract of this:
dbConn.Connnect(dbConn.DB_DRIVER, dbConn.DB_URL, dbConn.DB_USERNAME, dbConn.DB_PASSWORD);
dbConn.executeSQLOther("SELECT idOtherJourney, student_Student_num, Date, Arrive, Leave, Comments, JourneyType, numPassengers " +
"FROM OtherJourney WHERE student_Student_num = " + Integer.toString(Login.getUserID()));
for(int i = 0; i < dbConn.getRowCount(); i++){
//id2 = dbConn.getUser_other().getOther();
out.write("<tr align='center'>");
out.write("<td align='center' bgcolor='#0099FF'><b>journey ID:</b></td>");
out.write("<td>" + dbConn.getUser_other().getOther() + "</td>");
out.write("</tr>");
out.write("<tr align='center'>");//get To do tasks and write the html to display them
out.write("<td align='center' bgcolor='#0099FF'><b>User:</b></td>");
out.write("<td>" + Login.getUserName() + "</td>");
out.write("</tr>");
when the user wishes to modify their journies, they click on the modify link which takes them to another page with a form and relevant form items displaying their Journey details. From here the user may delete the journey, wich uses the following code:
if(request.getParameter("delete") != null){//if delete button pressed delete task from DB
dbConn.Connnect(dbConn.DB_DRIVER, dbConn.DB_URL, dbConn.DB_USERNAME, dbConn.DB_PASSWORD);
dbConn.updateSQL("DELETE FROM OtherJourney WHERE idOtherJourney=" + idOther);
dbConn.CloseConnection();
response.sendRedirect("Home.jsp");
return;
}
On the event of the user clicking the delete button to delete the journey, the journey is successfully deleted from the database, yet after the response.SendRedirect(); method I get the following error:
java.lang.ArrayIndexOutOfBoundsException: 2
I think this may be because, the journey is deleted from the database, yet the for loop on the home page is still trying to print out the journies with the same length as before, or something like this, im a bit confused. If anybody could help that would be amazing, im running out of time, thanks!
A.

