Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display a "wait... loading" message while the servlet is loading the other page?

 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a Servlet which performs a login task, but it takes some time to load because it uses a webservice that it is not very fast.
So, I'd like to display to the user a message saying "Please wait a little bit". How could I do that?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to do with Servlets, so moving to the HTML forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have ypu tried simply displaying a notice using a submit handler before the form is submitted?
 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Have ypu tried simply displaying a notice using a submit handler before the form is submitted?

How?

Now I've been trying this: http://malsup.com/jquery/block/#page
 
Hikari Shidou
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript is the way to go, Servlet is server-side you know.

As long as I know, once browser submits a request we can't control what happens until next page is loaded.

So, either you handle lag before loading the new page, or you handle lag after page is loaded. Of course, it's hard to load a page that requires authentication, before authentication is done, so better keep on login page until it happens.

My suggestion is that you handle login with AJAX, always being careful with security. Instead of letting browser submit the form, your JS gathers login information and asynchronously sends to Servlet using AJAX. I don't know how to do it but it can be done.

While your JS wait for response, you create some animation to distract user. Once responce comes, if it login succeeds, your JS loads the new page.
 
sonia caasi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yuah, javascript i guess is the one way to do your task, this is a tutorial site. hope it can help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic