servlet 是單列,因此不能保存數據html
jstl則是一個線程一個對象,目前是這樣:安全
<nest:parent id="1"> 第1個標籤:<nest:child key="key1" value="value1">--pageStart---${el }--sumi=${sumi } ---endPage--</nest:child> <br> 第2個標籤:<nest:child key="key2" value="value2"> --pageStart--${el }---sumi=${sumi } --endPage</nest:child> <br> </nest:parent>
如上:代碼所示, parent標籤的對象是一個,這個很好理解!線程
而child也是一個對象,可是它能保證執行玩一個標籤後,再只想下一個標籤,因此setValue此類方法的數據是安全的!code
標籤的執行過程是:htm
1 . parent 的 doStartTag對象
2.child的DoStartTagservlet
3.回到頁面執行${}語句;class
4.child的DoEndTage方法
5.parent的doAfterBody 是否再來一次執行2步驟到4步驟im
6.parent的 doEndTage方法
如圖: