Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

servlets - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...