• 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

pop up for new mail - mail application

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am developing an intranet mailing system,For which i want to create a servlet which checks for a new mail (new record in mail table) every 5 min, and if the reciever is logged in, the servlet should pop up a window stating new message arrival.
How should i go about it???
Anu
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
what have you got so far ?
the servlet can not just pop up a window on the client side. HTTP is a request response protocol. the servlet (the server) only sends data to the client when it received a request from a browser (the client)
you would need the client to reload a page every 5 minutes (javascript). depending on the state (new mail or not ) different pages are loaded (the normal page and one that additionally will pop up a "new mail arrived" window)
k
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can set a refresh header to reload your page every 5 minutes to make the work, or you can also
run a thread which will check
your table every 5 minutes.
 
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 did a same thing in one of my application. Your question could be divided into two questions
1) How to make a Servlet refresh every 5 mins?
This could be done by setting the Header attribute. This way the Servlet will get refreshed every 5 mins
2) How to display a new mail pop up?
The best and easy way to do this using the JavaScript. Have a Javascript function that does a pop window. Call that JavaScript function inside the BODY tag for "onLoad" . Enclose this "Onload" logic inside a "if" condition that checks whether new mail is present. This new mail present attribute will be set by the Servlet directing to this JSP.
I hope you get the idea
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>you can also run a thread which will check
> your table every 5 minutes.
How to do that? By running an object on the server side? if so, how it call the client for new mail??
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an ide is to make the client (a java progg running i tray maby) pull the server for new emails but the best way is if you make a socket connection so the server tells the client when new mails have arrived. check out JTray and desktopindicator hope it helps
 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi anu,
its very easy to have a mail popup..
i will tell u the way i have done this.
Divide the home page into frames.
let it has
. a top frame ( some links like back,logout)
. a left frame (for menu components)
. middle frame (for displaying the pages)

now divide the left frame into two
top frame with menu components
bottom frame for popup.
refresh the jsp (left bottom frame) every 1 or 2 minutes..u can find the java script code for page autorefresh on internet.check www.dynamicdrive.com
and in the jsp add a scriptlet to check if any new messages in the inbox
hmmm...i wll write the code
<%@ page import='CheckMailBean' %>
<% CheckMailBean mailbean = new CheckMailBean();
int newmail = mailbean.checkInbox(myID);
System.out.println("newmail = " + newmail);
String popup = null;
if (newmail > 0 )
{ popup = "<script> alert('new mail'); </script> ";
}
else
{ System.out.println("new mail count is ZERO");
}
%>
print that variable "popup" at the end of the jsp page after the </body> tag.. u can find codes for popup script on the above mentioned site .
is it clear..easy naa ???
raj

SCJP2
 
Anu Pasricha
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx a lot.
I have implemented the same using thread.
I have created a thread in login page, and the thread starts when login is correct.
The thread's run method checks for the condition and if new mail has arrived then instantiate a class which i extended from frame.
Regards,
Anu
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic