Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在我的JSP中显示加载消息_Jsp_Loading - Fatal编程技术网

如何在我的JSP中显示加载消息

如何在我的JSP中显示加载消息,jsp,loading,Jsp,Loading,当我点击一个按钮时,它会在服务器上执行一个批处理文件,这需要相当长的时间才能完成,所以我需要在我的页面上显示请等待消息,而该过程在后台执行。我的JSP中有以下代码 <% if(session.getAttribute("wait") != null){ session.removeAttribute("wait"); %> // this is 'wait' block <html> <head><title>searching.

当我点击一个按钮时,它会在服务器上执行一个批处理文件,这需要相当长的时间才能完成,所以我需要在我的页面上显示请等待消息,而该过程在后台执行。我的JSP中有以下代码

<%
if(session.getAttribute("wait") != null){
        session.removeAttribute("wait");
 %>
// this is 'wait' block
<html>
<head><title>searching...</title>
<meta http-equiv='Refresh' content='0'>
<style type="text/css">
.wait{
font-family: arial;
font-size: 13px;
color: #ff0000;
font-weight: bold;
}
</style>
</head>
<body>
<table align="center" valign="middle">
<tr>
<td class="wait">
Please wait, menus are being searched...
<br>
<img src="ajax-loader.gif" border="0">
</td>
</tr>
</table>
</body>
</html>
<%
}
else{
     session.setAttribute("wait", new String());
%>

// This is where process is executed.
<html>
<body>
<head>
<title>List</title>
</head>

<%
    try
        {
            Process p = Runtime.getRuntime().exec("cmd.exe /c start /wait my.bat");
            p.waitFor();
            out.print("The last update was on "+ sdf.format(file.lastModified()));

        }
    catch(Exception ex)
        {
            out.println(ex);
        }
%>

<p>
        <iframe src="../jsp/new_list.txt" frameborder="0" height="80%" width="95%"></iframe>
</p>

</body>
</html>

//这是“等待”区
搜索。。。
.等等{
字体系列:arial;
字体大小:13px;
颜色:#ff0000;
字体大小:粗体;
}
请稍候,正在搜索菜单。。。

//这是执行流程的地方。 列表


但是这里发生的事情是,当我点击按钮时,进程被执行,但没有消息出现,现在当批处理文件完成执行时,执行请求再次被触发,等待消息出现在屏幕上。请帮助我修复它。

在JSP中使用scriptlet不是一个好的实践

点击按钮即可显示加载图像的简单逻辑。
1.具有隐藏的加载图像
2.点击按钮显示加载图像。

3.当您从服务器收到响应时,隐藏加载图像。

单击按钮,将调用此JSP,该JSP将依次执行批处理文件,现在此批处理文件需要时间执行,我希望在此处加载图像。我认为你需要修改你的工作流程。加载浏览器客户端显示的图像,当您调用JSP时,它在服务器端执行。所以在调用jsp show loading image之前和执行完成hide loading image之后,我添加的代码应该也这么做,对吗?但事实并非如此。我如何在调用方JSP中知道另一个JSP已完成执行。