下载首页 | 资讯中心 | 下载分类 | 最近更新 | 排 行 榜 | 国产软件 | 国外软件 | 汉化补丁 |
文章搜索: 分类 关键字 收藏本站设为首页
您的位置:首页网页设计ASP程序 → JSP 构架-2种方式:Model I和Model II__教程
JSP 构架-2种方式:Model I和Model II__教程
日期:2007-5-20 1:18:54 人气:165     [ ]
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页

The second case is even more serious, as it can lead to great memory use if Sessions are defined to exist for more than the standard amount of time (30 minutes appears to be the standard). Even in the case of 30 minute Sessions, this Model can lead to disastrous memory leaks in systems under great use. Why? Objects get instantiated, set inside the Session object, and are not removed until the Session ends. Because they still have references (the Session object) pointing to them, they are not garbage-collected. In the Model II pattern, many objects are placed into the Session (either directly or via a JavaBean). As the Session progresses (more pages are accessed) memory-use increases and persists until the client ends the Session or the Session times out. Until the Session is invalidated, the objects placed there cannot be garbage-collected, and thus consume memory that could be of use elsewhere.

One means of addressing this issue is to place the Beans or other variables into the Request object, and use RequestDispatcher.include() rather than RequestDispatcher.forward(). By doing so, the View page has access to the same Request object as the Controller, and the weaknesses of the traditional Model II design are obviated.

One final comment: despite all the above, I have a personal distaste for the Model II paradigm as it is commonly implemented. The creation of a system where the client is sent to an address, but is redirected to a different class, is for some reason abhorrent to me. For this reason, I´ve modified the design in the following manner:

Controller: timeByZone2.jsp
As before, the controller uses the Request values to obtain the necessary data and put that data into the Request object. The difference this time is that the View page will call the Controller using RequestDispatcher.include(). In this way, the client is never redirected, and Requests are not "chained". Rather, the class/jsp called asks someone else to do some work for it, then continues.

======================================================================



//the parameter "zone" shall be equal to a number between 0 and 24 (inclusive)
TimeZone timeZone = TimeZone.getDefault(); //returns the default TimeZone for the server
if (request.getParameterValues("zone") != null)
{
String timeZoneArg = request.getParameterValues("zone")[0];
timeZone = TimeZone.getTimeZone("GMT+" + timeZoneArg + ":00");
// gets a TimeZone. For this example we´re just going to assume
// its a positive argument, not a negative one.
}
TimeBean timeBean = new TimeBean();
timeBean.setHours = myCalendar.get(Calendar.HOUR_OF_DAY);
timeBean.setMinutes = myCalendar.get(Calendar.MINUTE);
timeBean.setSeconds = myCalendar.get(Calendar.SECOND);
request.setAttribute("tempTimeBean", timeBean);
出处:本站原创 作者:佚名
 阅读排行
01.精美qq空间横幅代码
02.最酷qq个性女生网名
03.最新又有免费QQ秀啦《..
04.巧用透明FlaSh扮靓你的..
05.花之神匠代码(最新代码..
06.最新QQ空间免费导航
07.最新免费个人形象设置..
08.最新qq空间flash代码m..
09.CSS技术结合图像实现动..
10.Photoshop光影魔术师:..
11.QQ音速种子狂刷
12.最新QQ空间透明代码
13.PS实例教程:教你制作结..
14.Photoshop光影魔术师:..
15.制作背景图__教程
16.用Photoshop制作漂亮的..
17.如何获得QQ音速种子
18.≤QQ空间代码≥在日志..
19.网页浮动广告的制作代..
20.用Photoshop制作大红灯..
21.常用CSS
22.Photoshop给靓丽美女打..
 推荐文章
·Photoshop 表现技法之..
·快速将你的相片矢量化..
·PHOTOSHOP制作炽热的太..
·用Photoshop制作美丽的..
·流行杀手的娃娃工厂__..
·打造8号台球__教程
·PHOTOSHOP制作待机MM图..
·用Photoshop帮MM做纹身..
·PHOTOSHOP美眉着色绝招..
·PHOTOSHOP花露的制作_..
·PHOTOSHOP渐变工具的巧..
·PHOTOSHOP手绘奥兰多-..
·高难度抠图两种方法__..
·Photoshop高尔夫球的制..
·Photoshop打造精美玉佩..
Eqxia_COM下载站 版权所有 Copyright© 2001-2005 Www.eqxia.COM, All Rights Reserved.