• 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 page before finishing servlet stuff?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a user sign up form on my website. When info is submitted it goes to a servlet that puts it in a database and then is forwarded to a servlet that sends an email to the admin. Probably I should use JMS or something for this kind of thing, but for now I want to stick with the servlets and a couple of helper classes. I don't want the user to just stare at a blank screen while the info is processed (which should not take long, but anyway), how can I display a JSP of even a regular HTML page with some kind of "processing, please wait" message and then continue with the servlet stuff?

Thanks!
 
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
You can't.

If you want to do the processing in the background, fire off a thread to handle it asynchronously.
 
Vopli Vidoplyasova
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You can't.

If you want to do the processing in the background, fire off a thread to handle it asynchronously.



Thanks Bear, I see. Is it ok to have all that thread stuff in the servlet or should I use a separate class for that?
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I see. Is it ok to have all that thread stuff in the servlet or should I use a separate class for that


what does it mean?

If you mean the code to persist that in the DB and sending the mail to the user you should move that to a separate class.
 
Vopli Vidoplyasova
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Singh wrote:If you mean the code to persist that in the DB and sending the mail to the user you should move that to a separate class.


No, that's not what I meant. What you're saying is clear. I was wondering about the very code that starts a new thread like

I've never seen a thread-related code in a servlet before, thus the question.
 
Manish Singh
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

# Thread mailer = new Thread(new MailerBean(userData));
# mailer.start();



what is the use of above code ? is it placed inside the service method and its there to send the mail to the user?
 
Vopli Vidoplyasova
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manish Singh wrote:

# Thread mailer = new Thread(new MailerBean(userData));
# mailer.start();



what is the use of above code ? is it placed inside the service method and its there to send the mail to the user?


Manish, you do not override the service() method. The code is from doPost() and what it does should be pretty clear - it creates a new instance of a class responsible for emails and passes it the data received from the user.
 
reply
    Bookmark Topic Watch Topic
  • New Topic