refresh JSP webpage when jms message is received or Apache DBdatabase is changed

Discussion in 'Javascript' started by albert kao, Feb 8, 2010.

  1. albert kao

    albert kao Guest

    The goal is to refresh a JSP web page when a jms message is received
    or the Apache DB database is changed.
    How to do that with javascript or java?
    Is there any sample code?
    albert kao, Feb 8, 2010
    #1
    1. Advertising

  2. albert kao

    Erwin Moller Guest

    albert kao schreef:
    > The goal is to refresh a JSP web page when a jms message is received
    > or the Apache DB database is changed.
    > How to do that with javascript or java?
    > Is there any sample code?



    Hi,

    Sounds like you should poll the server from time to time from the client.
    You could use XMLHttpRequest to do this without a pagereload.

    Start reading here for a quick introduction:
    http://www.w3schools.com/ajax/

    On the server you could create a file that holds a timestamp (for example).
    Pull that file from your client every 60 secs or so. If it is changed,
    refresh the page and make sure you store the new value of the timestamp
    (via cookie or serverside scripting, whatever).

    Also, when you feel there is some reason for your clients to refresh
    (message arrived, db updated), simply update that file on the server
    with the new timestamp in it.

    Regards,
    Erwin Moller


    --
    "There are two ways of constructing a software design: One way is to
    make it so simple that there are obviously no deficiencies, and the
    other way is to make it so complicated that there are no obvious
    deficiencies. The first method is far more difficult."
    -- C.A.R. Hoare
    Erwin Moller, Feb 9, 2010
    #2
    1. Advertising

  3. albert kao

    albert kao Guest

    On Feb 9, 8:52 am, Erwin Moller
    <> wrote:
    > albert kao schreef:
    >
    > > The goal is to refresh a JSP web page when a jms message is received
    > > or the Apache DB database is changed.
    > > How to do that with javascript or java?
    > > Is there any sample code?

    >
    > Hi,
    >
    > Sounds like you should poll the server from time to time from the client.
    > You could use XMLHttpRequest to do this without a pagereload.
    >
    > Start reading here for a quick introduction:http://www.w3schools.com/ajax/
    >
    > On the server you could create a file that holds a timestamp (for example).
    > Pull that file from your client every 60 secs or so. If it is changed,
    > refresh the page and make sure you store the new value of the timestamp
    > (via cookie or serverside scripting, whatever).
    >
    > Also, when you feel there is some reason for your clients to refresh
    > (message arrived, db updated), simply update that file on the server
    > with the new timestamp in it.
    >
    > Regards,
    > Erwin Moller
    >
    > --
    > "There are two ways of constructing a software design: One way is to
    > make it so simple that there are obviously no deficiencies, and the
    > other way is to make it so complicated that there are no obvious
    > deficiencies. The first method is far more difficult."
    > -- C.A.R. Hoare


    Should the new value of the timestamp be stored at the client (not
    server)?
    i.e. On the server you could create a file that holds a timestamp (for
    example).
    Pull that file from your client every 60 secs or so. If it is changed,
    refresh the page and make sure you store the new value of the
    timestamp at the client.

    Also, when you feel there is some reason for your clients to refresh
    (message arrived, db updated), simply update that file on the server
    with the new timestamp in it.
    albert kao, Feb 9, 2010
    #3
  4. albert kao

    Erwin Moller Guest

    albert kao schreef:
    > On Feb 9, 8:52 am, Erwin Moller
    > <> wrote:
    >> albert kao schreef:
    >>
    >>> The goal is to refresh a JSP web page when a jms message is received
    >>> or the Apache DB database is changed.
    >>> How to do that with javascript or java?
    >>> Is there any sample code?

    >> Hi,
    >>
    >> Sounds like you should poll the server from time to time from the client.
    >> You could use XMLHttpRequest to do this without a pagereload.
    >>
    >> Start reading here for a quick introduction:http://www.w3schools.com/ajax/
    >>
    >> On the server you could create a file that holds a timestamp (for example).
    >> Pull that file from your client every 60 secs or so. If it is changed,
    >> refresh the page and make sure you store the new value of the timestamp
    >> (via cookie or serverside scripting, whatever).
    >>
    >> Also, when you feel there is some reason for your clients to refresh
    >> (message arrived, db updated), simply update that file on the server
    >> with the new timestamp in it.
    >>
    >> Regards,
    >> Erwin Moller
    >>


    > Should the new value of the timestamp be stored at the client (not
    > server)?


    Yes sure.
    The client should compare the timestamp found on the server with its own
    timestamp to decide if it needs a pagerefresh.
    You could use a cookie for this (or some variable parsed into JavaScript
    by the script that produces that page. Whatever is the easiest for you)


    > i.e. On the server you could create a file that holds a timestamp (for
    > example).
    > Pull that file from your client every 60 secs or so. If it is changed,
    > refresh the page and make sure you store the new value of the
    > timestamp at the client.
    >
    > Also, when you feel there is some reason for your clients to refresh
    > (message arrived, db updated), simply update that file on the server
    > with the new timestamp in it.


    Yes, the above sounds very familiar. ;-)

    Regards,
    Erwin Moller


    --
    "There are two ways of constructing a software design: One way is to
    make it so simple that there are obviously no deficiencies, and the
    other way is to make it so complicated that there are no obvious
    deficiencies. The first method is far more difficult."
    -- C.A.R. Hoare
    Erwin Moller, Feb 9, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Stein
    Replies:
    0
    Views:
    759
    Thomas Stein
    Oct 18, 2004
  2. Replies:
    0
    Views:
    921
  3. albert kao
    Replies:
    1
    Views:
    697
    Arne Vajhøj
    Feb 2, 2010
  4. Arne Vajhøj
    Replies:
    0
    Views:
    443
    Arne Vajhøj
    Feb 10, 2010
  5. albert kao
    Replies:
    1
    Views:
    154
    Arne Vajhøj
    Feb 2, 2010
Loading...

Share This Page