Posts

Showing posts from August, 2012

JavaScript: Remove all backslash (\) from a String in JavaScript

How to remove  all backslash (\) from a String in JavaScript Solution: function replaceAllBackSlash(targetStr){       var index=targetStr.indexOf("\\");       while(index >= 0){           targetStr=targetStr.replace("\\","");           index=targetStr.indexOf("\\");       }       return targetStr;   }

Google App Engine: Cloud Storage: java.lang.NoSuchMethodError: org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V

Uncaught exception from servlet java.lang.NoSuchMethodError: org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V     at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:133)     at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86)     at com.sun.jersey.core.util.Closing.f(Closing.java:71)     at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:83)     at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scan(FileSchemeScanner.java:71)     at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:223)     at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139)     at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)     at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)     at com.sun.jersey.api.core.Packa

facebook share button

------------------------------------------------------------------- 1) Using javascript   <div > <script>var fbShare = {google_analytics: 'true', size: 'small',url: 'http://knowledgeserve.in'}</script>     <script src="http://widgets.fbshare.me/files/fbshare.js"></script> </div> ------------------------------------------------------------------------------- 2) You can use FBML.... .       <div id="fb-root"></div>         <script>(function(d, s, id) {           var js, fjs = d.getElementsByTagName(s)[0];           if (d.getElementById(id)) return;           js = d.createElement(s); js.id = id;           js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=APP_ID"; // appId must be valid;                                                                                          //  for example: APP_ID=172095742912464           fjs.parentNode.insert

FileZila error: 421: Could not connect to server

FileZila connection error: 421 Sorry, cleartext sessions are not accepted on this server.  Error: Could not connect to server -------------------------------------------------------------- Please add a ftpes:// before the domain name Previous One, host : domain.com username : abcd pass : ****** port : 21 Change this, host : ftpes://domain.com username : abcd pass : ****** port : 21

Timesgroups interview questions: Servlet lifecycle : who called destroy() method of servlet

destroy() method is called by the servlet container. It is to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service() method have exited or after a timeout period has passed.      public void destroy() {       anyDB = null;     } How container knows that all the threads are exited and where we specify the timeout period for a servlet. For more, visit link : http://docs.oracle.com/javaee/1.4/tutorial/doc/Servlets12.html

Timesgroups Interviews questions: Iterate hashmap in java

You can use the following different ways..... 1: Iterating HashMaps over entries using For-Each loop. Use this if you need both map keys and values in the loop. Map<String, String> map = new HashMap<String, String>(); for (Map.Entry<String, String> entry : map.entrySet()) {     System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); } ------------------------------------------------------------------- 2. Filterating over keys or values using for-each loop....... If you need only keys or values from the map, you can iterate over keySet or values instead of entrySet. Map<Integer, Integer> map = new HashMap<Integer, Integer>(); //iterating over keys only for (Integer key : map.keySet()) {     System.out.println("Key = " + key); } //iterating over values only for (Integer value : map.values()) {     System.out.println("Value = " + value); } -----------------------------------------------------

Times group Interview questions: Method overloading/overriding

is it overloading? will it compile, if not then why ?   public void show(String a){     //.....     //...   }    public int show(String a){     //.....     //...    }   Solution: It is not mothod overloading as argument list must be different. It will not compile and compiler will give duplicate method error.

Timesgroup interview questions: Self JOIN with an example

A self-join is used when a table is joined (compared) to itself.  It means when you need to compare values in a column with other values in the same column in the same table.  Use of self-joins:  obtaining running counts and running totals in an SQL query.  Example: select emp1.name,emp1.salary,emp1.state   from employee emp1,employee emp2   where emp1.state=emp2.state;   ---------------------------------------------------   Name                     Salary          State   ---------------------------------------------------   Rajesh Singh           10250            Delhi   Kavita                     10850                Delhi   Kamal Singh           15250            Delhi   Rajesh Singh           20250            Haryana   Manish Kumar        15100            Haryana   ---------------------------------------------------