开发者

JSP processing message

probalby quite a dummy question, but that is not the area I work with usually...

I have html page "start.html" there is form which calls a serverlet via a post request. This servlet (JSP) is action.java there I have:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
    //please show a message that I am working

    // here is some code which takes 开发者_运维技巧some time
    response.sendRedirect(http://result.html);


}

So I do some processing then I show a page result.html. This all works fine, the problem is that upon pressing the send button in start.html I only see this little spinning wheel in IE that the system is processing and then I get the result. Most people probably would miss that little indicator. I would like to have an intermediate page or something with a progress bar, spinning wheel or even only a message "please be patient". As simple as possible. How can I achieve this?

Thanks!


Just put a loading animated gif in the form, initially hide it using CSS and then use JavaScript to show it up during submit of the form. As long as you don't write any byte to the HTTP response, the current page will just stick in the browser that long without going to blankout.

E.g:

<form onsubmit="document.getElementById('loading').style.display='block'">
    ...

    <img id="loading" src="loading.gif" style="display: none;" />
</form>

(you should actually put this in a .js and .css file)

You can get yourself some nice images from Ajaxload.info.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜