How to set session timeout dynamically in Java web applications?

Instead of using a ServletContextListener, use a HttpSessionListener. In the sessionCreated() method, you can set the session timeout programmatically: public class MyHttpSessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent event){ event.getSession().setMaxInactiveInterval(15 * 60); // in seconds } public void sessionDestroyed(HttpSessionEvent event) {} } And don’t forget to define the listener in the deployment descriptor: <webapp> … … Read more

windows service startup timeout

I agree with Romulo on finishing to start your service as soon as possible. However, if you need the time and you are using .NET Framework 2.0 or later, you might consider ServiceBase.RequestAdditionalTime() method. http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.requestadditionaltime.aspx protected override void OnStart() { this.RequestAdditionalTime(10000); // do your stuff }

Java URLConnection Timeout

Try this: import java.net.HttpURLConnection; URL url = new URL(“http://www.myurl.com/sample.xml”); HttpURLConnection huc = (HttpURLConnection) url.openConnection(); HttpURLConnection.setFollowRedirects(false); huc.setConnectTimeout(15 * 1000); huc.setRequestMethod(“GET”); huc.setRequestProperty(“User-Agent”, “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)”); huc.connect(); InputStream input = huc.getInputStream(); OR import org.jsoup.nodes.Document; Document doc = null; try { doc = Jsoup.connect(“http://www.myurl.com/sample.xml”).get(); } catch (Exception e) { … Read more

How to put a delay on AngularJS instant search?

UPDATE Now it’s easier than ever (Angular 1.3), just add a debounce option on the model. <input type=”text” ng-model=”searchStr” ng-model-options=”{debounce: 1000}”> Updated plunker: http://plnkr.co/edit/4V13gK Documentation on ngModelOptions: https://docs.angularjs.org/api/ng/directive/ngModelOptions Old method: Here’s another method with no dependencies beyond angular itself. You need set a timeout and compare your current string with the past version, if both … Read more