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方法
如图: