PreparedStatement stmt=DBInterface.doQuery("SELECT id FROM image WHERE owner=?");
stmt.setInt(1,userid);
ResultSet result=stmt.executeQuery();
while (result.next()) {
ImageBean temp=new ImageBean();
temp.setId(result.getInt(1));
list.add(temp);
}
result.close();
stmt.close();
DBInterface.close();
} catch (SQLException sql) {
throw new ServletException("Could not retrieve images: "+sql.getMessage());
}
}
//add list of images to the request and dispatch to view for creating galleries
request.setAttribute("imagelist",list);
RequestDispatcher dispatcher=request.getRequestDispatcher(GlobalHelpers.getIncludedUrl("gallerymgmt/new"));
dispatcher.forward(request,response);
} else if (action.compareTo("edit")==0) {
//user wants to delete an existing gallery
Vector<GalleryBean> list=new Vector<GalleryBean>();
//fetch list of galleries for the given user
synchronized(this) {
try {
int userid=(Integer)request.getSession().getAttribute("userid");
PreparedStatement stmt=DBInterface.doQuery("SELECT id,name FROM gallery WHERE owner=?");
stmt.setInt(1,userid);
ResultSet result=stmt.executeQuery();
while (result.next()) {
GalleryBean temp=new GalleryBean();
temp.setId(result.getInt(1));
temp.setName(result.getString(2));
list.add(temp);
}
result.close();