• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not much to do with Servlets, so moving to the HTML forum.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic