illegalstateexception

How to count the number of documents under a collection in Firestore?

◇◆丶佛笑我妖孽 提交于 2019-11-25 23:50:14
问题 I am trying to get CollectionReference count that exists on the Cloud Firestore, I have tried to get it with: FirebaseFirestore db = FirebaseFirestore.getInstance(); final CollectionReference postsCollection = db.collection(\"Posts\"); final TaskCompletionSource<Integer> source = new TaskCompletionSource<>(); new Thread(new Runnable() { @Override public void run() { int fromWhereToStart = postsCollection.get().getResult().size(); source.setResult(fromWhereToStart); } }).start(); Task<Integer>

java.lang.IllegalStateException: Cannot (forward | sendRedirect | create session) after response has been committed

梦想与她 提交于 2019-11-25 21:47:23
问题 This method throws java.lang.IllegalStateException: Cannot forward after response has been committed and I am unable to spot the problem. Any help? int noOfRows = Integer.parseInt(request.getParameter(\"noOfRows\")); String chkboxVal = \"\"; // String FormatId=null; Vector vRow = new Vector(); Vector vRow1 = new Vector(); String GroupId = \"\"; String GroupDesc = \"\"; for (int i = 0; i < noOfRows; i++) { if ((request.getParameter(\"chk_select\" + i)) == null) { chkboxVal = \"notticked\"; }