JSP页面多线程和进度条的问题!
小弟最近碰到这个问题了,请指点下!
问题描述:
从前一个JSP页面传很多参数过来,在当前JSP页面拿到参数之后,开始处理(这个过程很长,有时数据多可能上1个小时),目前是直接在当前页面处理的,时间一长,页面老是死掉,没有任何的信息,IE加载的进度条只有5格就永远不动了!
现在想做成这样的:当前JSP页面拿到参数之后,把费时的操作放到另一个JSP页面(这个大操作不单单是一个java方法,用到了一套自定义标签,所以只能放在jsp页面里做),而当前的页面则显示一个进度条,从处理大操作的JSP页面获取信息。请教如何实现?!因为这个操作有牵扯标签,所以我的理解是一定要放在jsp页面里做,这样就不知道怎么用多线程,要是单纯的java方法的话,倒还可以试着实现~~~~~~~高人请指点一下,或有什么好的建议,不甚感激!
[解决办法]
正在研究
[解决办法]
可以用ajax技术处理,每隔一段时间提交一次,返回进度值
[解决办法]
别用jsp做逻辑处理
[解决办法]
写servlet
处理都放在里面
至于进度条放在提交页面,用js
showLoadingBar();
如下:
/*
*在表单form提交前,调用showLoadingBar(),灰显表单页面,显示请等待信息。
*/
function showLoadingBar(){
var Br = new innerMessageBox();
Br.ShowModal( 250, 30);
}
function innerMessageBox(){
var BackObject, FormObject;
// 检查页面中是否存在该控件.
function checkIMBObject(){
if (document.getElementById( "imb_Background ")==null && document.getElementById( "imb_FormModal ")==null){
document.body.innerHTML += " <iframe id=\ "imb_Background\ " src=\ "about:blank\ " style=\ "position:absolute;left:0;top:0;width:0px;height:0px;visibility:hidden; \ " frameborder=no border=0> </iframe> "
+ "\r\n <iframe id=\ "imb_FormModal\ " src=\ "about:blank\ " style=\ "position:absolute;left:0;top:0;width:0px;height:0px;visibility:hidden;border-style:solid;border-width:1px; border-color:#3399FF\ " frameborder=\ "0\ " > </iframe> ";
window.imb_Background.document.open();
window.imb_Background.document.write( " <html> </html> ");
window.imb_Background.document.close();
window.imb_FormModal.document.open();
window.imb_FormModal.document.write( " <html> ");
window.imb_FormModal.document.write( " <head> </head> ");
window.imb_FormModal.document.write( " <body style=\ "position:absolute;padding:7px 9px 2px 50px\ " scroll=\ "no\ " leftmargin=0 topmargin=0 style=\ "background-color:#FFFFCC; font-size: 9pt; font-FAMILY: \ "宋体\ ";\ "> ");
window.imb_FormModal.document.write( " <tr> <td> ");
window.imb_FormModal.document.write( " <img src=\ "/corporbank/images/loading.gif\ " align=\ "absmiddle\ "/> ");
window.imb_FormModal.document.write( " 交易理中,稍候。…… ");
window.imb_FormModal.document.write( " </td> </tr> ");
window.imb_FormModal.document.write( " </body> ");
window.imb_FormModal.document.write( " </html> ");
window.imb_FormModal.document.close();
}
}
// 显示对话框控件.
this.ShowModal = function( iWidth, iHeight){
var smWidth = 250, smHeight = 30, smObject, smAlpha = 0, smInterval;
if (arguments.length > 4 ){
smWidth = iWidth;
smHeight = iHeight;
}
// 背景的渐显.
function checkIMBAlpha(){
smObject.style.filter = "alpha(opacity= "+smAlpha+ "); ";
smAlpha += 10;
if (smAlpha> 80){
clearInterval(smInterval);
}
}
checkIMBObject();
this.BackObject = document.getElementById( "imb_Background ");
this.FormObject = document.getElementById( "imb_FormModal ");
smObject = this.BackObject;
smAlpha = 0;
this.BackObject.style.left = 0;
this.BackObject.style.top = 0;
this.BackObject.style.width = document.body.scrollWidth;
this.BackObject.style.height = document.body.scrollHeight;
checkIMBAlpha();
this.BackObject.style.visibility = "visible ";
smInterval = window.setInterval(checkIMBAlpha, 5);
//if( document.body.scrollHeight > document.body.clientHeight)
//{
this.FormObject.style.left = document.body.clientWidth/2 - smWidth/2;
this.FormObject.style.top = document.body.scrollTop + (document.body.clientHeight- smHeight -
window.parent.frames[0].document.body.clientHeight - window.parent.frames[1].document.body.clientHeight)/2;
//}else{
// this.FormObject.style.left = document.body.clientWidth/2 - smWidth/2;
// this.FormObject.style.top = document.body.clientHeight/2 - smHeight/2;
//}
this.FormObject.style.width = smWidth;
this.FormObject.style.height = smHeight;
this.FormObject.style.visibility = "visible ";
//document.body.scroll= "no ";
}
}
[解决办法]
另外说明jsp==servlet,所以你可以要在jsp里处理的都可以在servlet里面处理
[解决办法]
现在想做成这样的:当前JSP页面拿到参数之后,把费时的操作放到另一个JSP页面(这个大操作不单单是一个java方法,用到了一套自定义标签,所以只能放在jsp页面里做)
------------------------
这是个很奇怪的说法,你还是没有剥离处费时的操作在什么地方,如果真像你说的无法剥离,那你的架构就有很大的问题。
[解决办法]
可否贴下你的带有Tag的代码看看
[解决办法]
Tag,也是你自己写的servlet,用web.xml配置成tag,tag的逻辑完全可以写在你准备写的大操作里面;
另外你贴个代码,只是程序代码级的讨论,对于你的项目没有任何泄密,人家想探密也只是冰山一角,晕
[解决办法]
你难道真要在JSP中处理吗?在servlet里面行不?