[JSP ] 有關out.close()
是這樣的 小弟寫了一個jsp網頁
程式內容大概如下
while((line = correctExecuteInfo.readLine()) != null{
out.println(line+"<br/>");
out.flush();
}
</body>
</html>
<% out.close();
shutdownService();%> /// 這裡會執行約30sec
當程式跑到out.close()時 會出現stream error excption
但我確定後面並沒有任何資料要輸出了
(因為shutdownService()是屬於model的部分)
程式原意是這樣 我希望能將執行結果印出
印完後我必須關掉特定service,但網頁中因執行了shutdownService()
所以 網頁一直處於loading狀態.
但我希望網頁不須處於loading 但 程式能執行到最後一行的shutdownService()
想請問各位前輩跟高手們 這應該怎麼做比較好.
是否是out.close()有什麼需要注意的嗎?
pm 4:57
對了 我先前先使用servlet寫的時候 並不會遇到excpetion
其原因是?
pm 5:32
我已經找到您說的 ***_jsp.java了
out.write("\n");
out.write("</body>\n");
out.write("</html>\t\t\t\t\t\t\t\t\n");
out.write("\t ");
out.flush(); // 這行有放跟沒放都會出現Stream closed
out.close();
executeService.ShutDowm_Service(task);
} catch (Throwable t) {//省略...
} finally {
//省略
}
但 似乎後面的確沒有關於jsp的output了
pm 5:39
還是需要的是改換我的程式想法呢??- -q
pm 6:35
嘗試將shutdownService() 註解
並在最尾端(包括/<body> 與 </html>)
之後再將
out.flush();
out.close();
還是會出現stream closed @@
pm 7:12
確認buffer 已經清乾淨為8192後 才執行out.close();
還是出現stream closed @@
pm 8:17
其原因找到了..
close
public abstract void close()
throws IOException
Close the stream, flushing it first.
This method needs not be invoked explicitly for the initial JspWriter as the
code generated by the JSP container will automatically include a call to
close()
但要怎麼不讓容器幫我close這個out,該改寫哪一段code @@
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.126.162.22
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 16:57)
→
02/23 17:05, , 1F
02/23 17:05, 1F
→
02/23 17:15, , 2F
02/23 17:15, 2F
→
02/23 17:19, , 3F
02/23 17:19, 3F
→
02/23 17:27, , 4F
02/23 17:27, 4F
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 17:37)
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 17:40)
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 18:39)
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 19:14)
※ 編輯: simon8233 來自: 59.126.162.22 (02/23 20:19)
→
02/23 23:22, , 5F
02/23 23:22, 5F
→
02/24 00:34, , 6F
02/24 00:34, 6F
→
02/24 01:02, , 7F
02/24 01:02, 7F
→
02/24 10:33, , 8F
02/24 10:33, 8F
→
02/24 17:26, , 9F
02/24 17:26, 9F
→
02/24 17:36, , 10F
02/24 17:36, 10F
已經附上轉出的result.jsp
非常感謝你一直幫我找解決的方法@@ 我也還在想看看是不是能從model那邊下手更改的問題
※ 編輯: simon8233 來自: 59.126.162.22 (02/24 17:36)
※ 編輯: simon8233 來自: 59.126.162.22 (02/24 17:37)
→
02/24 19:14, , 11F
02/24 19:14, 11F