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

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

Android httpclient file upload data corruption and timeout issues

See My Code of Image Uploader and it worked great for me This class Uploads a file to the server plus in the end read the XML reply also. Filter the code as per your requirement.. It worked pretty smooth for me package com.classifieds; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.HttpURLConnection; import … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)