How to set a timeout for a given action in Java?

0

I would like to set a timeout for a given action on JSP pages, which should work with the following conditions below:

  • When I click on a button eg "Traveling" , the page should somehow save start time and end time and say how long it takes to reach a certain destination.

  • When I'm not on the page, the time should continue.

  • When I enter the page again, the page should show me how much time remaining is left to reach a certain destination from second to second.

  • Making use of this:

    To determine how long the user will be able to perform the same action in the web application again, there should be intervals.

        
    asked by anonymous 23.06.2015 / 22:30

    1 answer

    2

    Hi @Luiz Ricardo Cardoso,

    As we speak, what you need is WebSocket Protocol . A technology not only very fun but also powerful.

    Here's the official technology link that's directly linked to HTML 5

    link

    In this next link you will find an excellent documentation / tutorial using Spring MVC

    WebSockets with Spring MVC

    Well, do you need something in Portuguese? Just got it!

    Stuff in Portuguese - Jetty + Java + WebSockets

    Is there a JSR for using WebSockets in Java?

    Yes: JSR 356

    What are your characteristics of this JSR?

    • Annotated targeting, allowing developers to use POJOs with the life cycles of WebSocket events

    • Interface-oriented programming (implement interfaces), allowing developers to use POJOs with the life cycles of events
      WebSocket

    • Integration with other Java EE technologies - you can inject objects and EJBs such as Contexts and Dependency Injection

    Hope you enjoy.

    I can not stop talking on the client side! ;)

    Take a look at AngularJS for building your application (it's not essential to know AngularJS, but you might find it interesting)

        
    24.06.2015 / 04:46