AJAX polling alternatives

I recently started investigating the AJAX framework and have a couple questions/concerns. I think the greatest possible benefit of AJAX could be in streaming data. That is, only sending out new XML to the client when there is some state change in the database. This unfortunately seems impossible because you cant listen for an uninitiated server message from within the browser.
So the only alternatives to polling are leaving persistent http connections open between client and server which eats up server resources. My problem with polling is that my users are likely to pull less data just navigating through a synchronous front end than they would use if all the data was being refreshed periodically through polling. So only real benefit is that the client app runs slightly faster because it already has [possible expired] data stored on the front end.
Does anyone have any clever ideas about this? My one thought is to add a 'last-update' field in the user table and an additional state_change table for all other types of data on the site. Instead of polling asynchronously, i would only pole when a user naviages to a different page, but instead of pulling all the data, i would just do a quick search of the last_update date, and if my front end cached data is still the latest version, do nothing else. Only if last_update is new would i reload the XML data.
Anyway, if anyone else has any thoughts, suggestions, or alternatives, i would definately like to hear. thanks a lot.
PHP/MySQL

Have you taken a look at Comet? This is trying to solve this issue.
http://www.ajaxian.com/archives/comet-a-new-approach-to-ajax-applications
-Larry

Similar Messages

  • To display a message after respose.redirect download

    Hi All,
    I have jsp page where in the only code I have is a <%
    response.sendRedirect("/cz_CZ/songs/angelique_song.zip");
    %>. Now this starts the browser download window and asks the user to download the zip file.
    Now, what i want is once the user completes the download I want to display thank you message. I don't mind using javascript. How can I do it?
    Thanks in advance for your help.
    THanks!
    harsh

    The only way I see this working is with some crazy ajax polling logic.
    1) create a servlet that will pump the data from the server to the client in stead of directly linking to the file
    2) load this servlet in a hidden iFrame so that your main page stays untouched
    3) when the servlet is done transferring the file to the client, set some flag to true, for example in the session
    4) in the webpage, use Ajax to poll (can be done with a javascript timer) for the status of the flag. Once it is true, display the thank you message
    JQuery has an easy Ajax routine to use. You can create a simple servlet that will output the value of the flag to the response and read that out using an Ajax call.
    [http://api.jquery.com/jQuery.ajax/|http://api.jquery.com/jQuery.ajax/]
    I'm pretty sure this technique can work, but I've never implemented it so I'm not 100% sure.

  • How to pass spry {} variables to PHP query sentence?

    I am trying to integrate AJAX poll system to a spry data set.
    My goal is to dynamically generate a poll fom associated with the id no. of each data item.
    So, I need to pass a spry xml variable covered by { } to a PHP query sentence.
    How? Is there any existing Spry poll solution? Thanks.

    The following sentence has been inserted into my code, but it doesn't work:
    <span spry:if="'ds_RowCount' == '0'">No Data to Display</span>
    ====
    <div spry:region="ds1" class="SpotlightAndStacked">
      <div spry:repeat="ds1" class="SpotlightAndStackedRow">
        <div class="SpotlightContainer">
          <div class="SpotlightColumn"> Type:{type}</div>
          <div class="SpotlightColumn"> Title:{title}</div>
          <div class="SpotlightColumn"> Username:{username}</div>
        </div>
        <div class="StackedContainer">
          <div class="StackedColumn"> <img src="upPhoto/{image}" width="144" height="144"/></div>
        </div>
        <br style="clear:both; line-height: 0px" />
      </div>
    <span spry:if="'ds_RowCount' == '0'">No Data to Display</span>
    </div>
    ====

  • Non-blocking jsp

    Hi,
    I am using Java in order to create web application.
    The application has to load a form which is sent it's data to a jsp that call a long business logic.
    I need that the jsp will return a message like "thank you for using my service, an email will sent to you when the proccess is done."
    The problem is that if I will write something like:
    <html>
    <head></head>
    <body>
    <span>thank you for using my service, an email will sent to you when the proccess is done</span>
    <% businessClass.doLongOperation(); %>
    </Body>
    </html>
    the jsp will run for long time and the user will have to wait for the operation to end. Moreover, i f the user will close the browser, I am not sure if the jsp will continue its job.
    How can I isolate the long operation from the jsp so the user will not have to wait all the execution time and also how can I make the long operation execution not to be depend on the browser?
    Naor

    Fire a new thread and monitor the progress using HTTP refreshes or Ajaxical polls or just completely ignore it and let the user wait for mail.

  • Page change as reaction to a jms message

    Is it possible to display another page as a reaction the receipt of a jms message in a JSF managed bean?
    If yes how so? I know the JMS part, but have no idea how to trigger the navigation.
    Thank,
    Hans

    Since the client (browser) triggers navigation requests, you aren't going to do it through a JMS message which is received asynchronously on the server. The client simply doesn't know anything happened.
    The only way I see it happening is if you have some kind of ajax poll on the client side. When you receive the JMS message you set some flag somewhere that will make the poll logic do a redirect. The ugliness and fragility of such a solution alone would make me search for other ways to fulfill your requirement.

  • Method call before visual web jsf page loads

    Hi All.....
    I have written a method in a java class that accesses the mysql backend db to check if a process is still running. If the process is still running, a JOptionPane is produced informing the user of this and offers an <ok> option(to check the process status again) and a <cancel> option(to redirect the user to the homepage). If the process is completed, I want the page to just load as normal. I want this method to be called before the visual web jsf page loads. I have the method call in the super_init() method of the page and everything seemed to be working fine, the problem I have run into is that if I set the value in the db to show the process is running, the JOptionPane is produced(like it should be), and then if I set the value to show the process has completed and choose <ok> from the pane, the page loads.....this is what I want. Now, after the page loads, if I set the value in the db to show the process is running again, the JOptionPane is produced again right after I apply the changes to the db edit!!!!. I don't know why this is happening. Should I be calling the method from somewhere other the super_init()????? I have tried the method call in the prerender(), preprocess(), and destroy() methods all with the same results.
    Anyone have any ideas on what the problem could be??
    Thanks in advance.
    Silgd

    The Java part of a JSP/Servlet based webapplication runs physically at the server machine.
    Only the HTML/CSS/JS part which is generated by the webapplication and sent to the client physically runs at the client machine.
    JOptionPane is a Java Swing component which thus runs at the server machine. So you as client would only see it when both the server and the client runs at physically the same machine. Which is often only the case in development environment and doesn´t occur in real life! There is normally means of two physically different machines connected through the network/internet.
    To solve your actual problem, look for Ajax poll techniques. To display an alert or confirm dialogue in the client side, you use Javascript for this.

  • How to know through code if the web page is modified on a particular site ?

    Hi all..
    I have an application developed using struts framework. In my application i accept URL from user and
    then connect to that URL. After that i retrieve the contents of that URL and do further processing. I have an action class which does these things. I store these processed contents in database along with the URL.
    The requirement is that if some other user requests with the same URL in my application, that time already processed data from database shall be used.
    As we know web sites keep on modifying its pages from time to time. I want some routine with which i can check if the issued URL ( specific web page ) is actually modified or not. It it is so , i will connect to actual URL and if no then i will use the data already stored in database . Is that possible ?
    What are the possible ways to implement the same ?
    Can any one have solution in this regard ?
    Thanks in advance..
    Prasad

    Use Ajaxical polls to inform the server if there isn't any update. If so, change page accordingly using JS+DOM.
    You can't do that from the server side on. The HTTP protocol fortunately disallows pushing responses.

  • Servlet : how to implement isclientconnected

    Is there a way to check if a client is still connected to the response.

    You may consider kind of timed AJAX polls/pings from
    the client to the server to let the server know that
    the client is still alive.I'm talking of a 30 giga, 60 table database with queries joining till 10 tables & views.
    I'm searching for a decent ajax solution now, but can't find one.
    http://ajaxpatterns.org/Periodic_Refresh
    or
    http://ajaxpatterns.org/Heartbeat
    looks interresting

  • Server Side Page Buffering

    I have the following page flow that I would like to mimic:
    1: User enters criteria on a page, search or otherwise
    2: Page is submitted (server starts rendering a page that takes a long time)
    3: The user is redirect to a page w/ an AJAX query that poll's the server to see if the page is rendered, if not wait, repeat
    4: Page is fully rendered in a server side buffer, the next AJAX poll from the client redirects the client to the rendered page
    This is very akin to Orbitz/Travelocity/Expedia which show you while your flight information is searched for.
    The page that is rendered deals with millions of records and can not be sped up using SQL tuning (any more than is) and the functionality/logic the query performs is as slim as can be. Assume materialized views and region caching are not options due to business rules, data constraints, and data volatility.
    From what I understand of OWA_UTIL, HTP, and APEX this is not possible. I am hoping, beyond hope, that someone has the solution.

    Meta tag only works for refreshing the client page; to make sure the server sends a refresh - put whatever needs refreshing (in my case a table from a database) into a prerender() method that gets invoked each time just before the page is rendered :)

  • How to make ProgressBar work for long process with finally download action

    Hi ADF-Experts,
    i wonder if there is a adf-solution to this use case.
    In my case the user clicks a context-menu item to get a report. So a background process will be started to generate the report(in pdf format) and when the generation is finished,
    the user can choose to download the report in the browser built-in popup.
    This all works, but because the generation process could take a long time, i want now to showing a progess bar in clock form with af:progressIndicator to inform the user about the running process.
    public void clickGenerateMenuItem(event) {
    startProgressBar();
    generateReport();
    private void generateReport() {
    doGeneration();
    stopProgressBar();
    downloadReport();
    The problem is that the ProgressBar will never be shown bacause of the call of generateReport()-methode. It is impossible in one request to make two different event (one for download and another for popup show/hide).
    I also tried with af:poll together with af:progressIndicator, the ProgressBar is indeed shown but because of the native Ajax-Poll Request the generated Report can not be downloaded more.
    Any idea how this problem could be answered?
    Thanks in advance.
    Regards
    Peng

    Hi,
    no, you can't make to calls. But you could show an animated gif instead. Have a look at sample 027 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html
    Frank

  • JSF session length - how to set? ViewExpiredException - how to avoid?

    Hi! Is there something like JSF session? If yes, how can I set its length so that ViewExpiredException is not being thrown so fast? After I restart my server, httpSession in my browser still exists, but ViewExpiredException is thrown. Is there a way to eliminate completly this exception from JSF application??? PLEASE HELP!

    cocolino81 wrote:
    Thanks for help. The problem is also that <session-timeout> is for example 1 hour and I get ViewExpiredException after 15 minutes!This was because you restarted the server or redeployed the application, is it? Besides, this would also occur if you use an IDE and are still actively developing the webapp. Tomcat will redeploy automatically on every change of one of the deployed files.
    If you read this, please write how do you deal with this excpetion. I would really like to know all your solutions. Thanks in advance.Depends on the purpose of the application. If the user have to be logged in, then I would just set a clear and user-friendly error-page which informs the user that the session has expired and that the user has to re-login. If there is no means of a login but the user just have to enter and submit a form, I would rather keep the session alive using ajaxical polls from the form on. If there is even no means of a form and you used commandlinks/buttons and navigation cases for navigation, then I would get rid of that way of navigation and just use outputlinks for navigation.

  • Runtime print out on the ServletOutputStream (like a printout on console)

    Hi all,
    i need to do a thing.
    I've a webapp with a lot of output. i would printout on a servlet the output of this project but in realtime.
    my first trial was to pass the servletoutputstream to the other classes and use this stream to printout the output. But the output is displayed only when the process is done.
    how can i see the output when the process is still running?
    thanks

    ELStefen wrote:
    thanks for your reply,
    i solvedi in this way:
    i create a static class that has an hasmap<String,Vector> the string is the key, the vector is all the output.
    this class has some method to fill in the vector.
    when the computation is finished i retreive the vector from the class and printout all the things.
    if i want to do in realtime i only need to create an ajax poller system that takes the data from that class.
    is working an i think is good enough.
    thanksI just want to (re) caution you that this will eventually lead to problems. You are storing everything in memory. Ideally (and this includes your algorithm for processing), you want to read from a stream and hold onto only the items that are necessary in memory. For example, aggregated values like totals or ongoing calculations. Storing everything in memory "works" (and works fast) but normally shows issues when you have multiple users or multiple simultaneous requests (or both).
    - Saish

  • Servlet to Browser

    Hi Friends.
    Suppose a browser sent a request to servlet and servlet replied. After that, can servlet send data to this browser again without browser making a request? If so, how?
    Thanks.

    Servers indeed can't push to clients. But it's virtually possible with AJAX poll.

  • Polling DB Adapter error in Jdev 11.1.1.5

    Hi,
    I have a table on a schema in an XE database which I am trying to poll. One of the columns in the database is of a VARRAY Collection Type.
    I go through the Database Adapter Wizard steps as per usual, importing the table etc etc. However, when I get to choosing the 'After Read' operation, whenever I choose the first one, 'Delete the Row(s) that were read' which is always selected by default, I am unable to press 'Next' and get on to the next screen/step in the wizard. Clicking on the operation radio button again then gives the following error message:
    java.lang.ClassCastException: org.eclipse.persistence.mappings.structures.ObjectArrayMapping cannot be cast to org.eclipse.persistence.mappings.CollectionMapping
         at oracle.tip.tools.ide.adapters.designtime.adapter.xr.XRAdapterPollingOptionsPage.refreshOrderByFieldChoices(XRAdapterPollingOptionsPage.java:690)
         at oracle.tip.tools.ide.adapters.designtime.adapter.xr.XRAdapterPollingOptionsPage.initialize(XRAdapterPollingOptionsPage.java:191)
         at oracle.tip.tools.ide.adapters.designtime.adapter.xr.XRAdapterPollingOptionsPage.<init>(XRAdapterPollingOptionsPage.java:122)
         at oracle.tip.tools.ide.adapters.designtime.adapter.xr.XRAdapterAfterReadPage.addFollowingPages(XRAdapterAfterReadPage.java:386)
         at oracle.tip.tools.ide.adapters.designtime.adapter.xr.XRAdapterAfterReadPage.actionPerformed(XRAdapterAfterReadPage.java:418)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:291)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at oracle.bali.ewt.olaf2.OracleButtonListener.mouseReleased(OracleButtonListener.java:44)
         at java.awt.Component.processMouseEvent(Component.java:6289)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
         at java.awt.Component.processEvent(Component.java:6054)
         at java.awt.Container.processEvent(Container.java:2041)
         at java.awt.Component.dispatchEventImpl(Component.java:4652)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4482)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
         at java.awt.Container.dispatchEventImpl(Container.java:2085)
         at java.awt.Window.dispatchEventImpl(Window.java:2478)
         at java.awt.Component.dispatchEvent(Component.java:4482)
         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
         at java.awt.EventQueue.access$000(EventQueue.java:85)
         at java.awt.EventQueue$1.run(EventQueue.java:603)
         at java.awt.EventQueue$1.run(EventQueue.java:601)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
         at java.awt.EventQueue$2.run(EventQueue.java:617)
         at java.awt.EventQueue$2.run(EventQueue.java:615)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:178)
         at java.awt.Dialog$1.run(Dialog.java:1046)
         at java.awt.Dialog$3.run(Dialog.java:1098)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Dialog.show(Dialog.java:1096)
         at java.awt.Component.show(Component.java:1585)
         at java.awt.Component.setVisible(Component.java:1537)
         at java.awt.Window.setVisible(Window.java:842)
         at java.awt.Dialog.setVisible(Dialog.java:986)
         at oracle.bali.ewt.wizard.WizardDialog.runDialog(WizardDialog.java:382)
         at oracle.bali.ewt.wizard.WizardDialog.runDialog(WizardDialog.java:298)
         at oracle.tip.tools.ide.adapters.designtime.adapter.techAdapterWizard.display(techAdapterWizard.java:364)
         at oracle.tip.tools.ide.adapters.designtime.adapter.DbScaEndpointImpl.createImplementation(DbScaEndpointImpl.java:86)
         at oracle.tip.tools.ide.fabric.gui.controller.ActionExternalReferenceEdit.add(ActionExternalReferenceEdit.java:145)
         at oracle.tip.tools.ide.fabric.gui.controller.ActionExternalReferenceEdit.process(ActionExternalReferenceEdit.java:108)
         at oracle.tip.tools.ide.fabric.gui.controller.DiagramController.processActionRequest(DiagramController.java:354)
         at oracle.tip.tools.ide.fabric.gui.components.ManagerView$1.run(ManagerView.java:526)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
         at java.awt.EventQueue.access$000(EventQueue.java:85)
         at java.awt.EventQueue$1.run(EventQueue.java:603)
         at java.awt.EventQueue$1.run(EventQueue.java:601)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    I then choose the 'Logical Delete' option as an alternative. This allows me to get past the current screen and on to the next one. However, I am then unable to get past the 'Logical Delete' option screen.
    I am not sure why it is doing this. I have successfully created DB Adapters before that call stored procedures with VARRAY Collection Types defined and I have also created polling adapters for tables with normal datatypes (string, integer, boolean) successfully before. This is the first time I am polling a table with a VARRAY Collection Type column and am wondering whether anyone has experienced this before or whether they could give this a try to see what the error is and how to resolve it please?
    I have installed Jdeveloper 11.1.1.5 locally along with XE database. Have tried in 11.1.1.3 Jdeveloper and it works OK, but it doesn't work in 11.1.1.4 either.
    Thanks

    I encountered the same problem and found the following workaround:
    1. Create a copy of the table without the collection type column.
    2. Go through the Database Adapter Wizard and finish it normally.
    3. Next, modify the created Dataabse Adapter but now select the original table with the collection type column.
    4. You should now be able to finish the wizard without any problems.

  • Eprint error creating account: Ajax submit failed: error = 403, Forbidden

    I am trying to create an eprint account. but when I hit submit I get:
    Ajax submit failed: error = 403, Forbidden
    I am running from a mac with OSX 10.8. And a new HP Photosmart 6515. The browser is Safari version 6.0.
    I've tried different namse, screen names passwords etc....
    THANKS,
    Tim
    This question was solved.
    View Solution.

    Hi there, this issue can usually be resolved by deleting your browsers cache and restarting the browser. Other forum users have confirmed that using an alternative browser type can also work (Mozilla FF and Google Chrome have both been cited).
    Try these suggestions and see how you get on.
    If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
    If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
    I am an HP employee.

Maybe you are looking for