Posts

Set your application context path in Tomcat 7

Set Context path in Tomcat 7 or more using catalina.properties file, Step 1) Add following lines to catalina.properties file under <tomcat-install dir>/conf directory, #myApp war file version myApp .war=myAppLive -1.0.0.1.war myApp .path=/myAppLive #application deployment location appBase=webapps Step 2) Now update context path in <Host> node in server.xml file in same location, <Host name="localhost"  appBase="webapps"             unpackWARs="true" autoDeploy="false"> ... ....     <Context path="${myApp .path}" docBase="${catalina.base}/${appBase}/${myApp .war}"/> ... .... </Host>

Custom directive with dynamic attribute using angular JS

Custom directive with dynamic attribute using angular JS Javascript: var myApp=angular.module('myApp', []); myApp.controller('myCtrl', ['$scope', function($scope) {    $scope.data= [                { name: 'A', size: '12' },                { name: 'C', size: '11' },                { name: 'B', size: '10' }               ]; }]) .directive('myOrderList', function(){   function link(scope, element, attrs) {        var myData=scope.data;            console.log(attrs);            var ulElem=element.html('<ol>');        for(var i=0;i<scope.data.length;i++){                         ulElem.append('<li>'+scope.data[i][attrs.valu...

Maven build is failing to include struts-config.xml or web.xml file to target../../WEB-INF directory

  Maven build is failing to include struts-config.xml or web.xml file to target../../WEB-INF directory due to ‘WebContent ‘ as maven needs ‘ webapps ‘ Add this plugin to pom.xml < plugin > < groupId > org.apache.maven.plugins </ groupId > < artifactId > maven -war- plugin </ artifactId > < version > 2.2 </ version > < configuration > < webResources > < resource > < directory > ${ basedir }/WebContent </ directory > </ resource > </ webResources > < warSourceDirectory > WebContent </ warSourceDirectory > < warSourceExcludes > WebContent/WEB-INF/ lib /*.jar </ warSourceExcludes > < archiveClasses > false </ archiveClasses > </ configuration > </ plugin >

Dynamic response by java and handle using ajax jquery for all content types

Dynamic response by java and handle using ajax jquery for all content types Jquery ajax call              var url= "trackDynamicResponse.do" ;               $.ajax({                                                   url: url,                        type: 'GET' ,                        data :{                    ...

Open popup window with post request data in Javascript

 Open popup window with post request data using javascript:                                  function openWindowWithPostRequest() {            var winName='MyWindow';            var winURL='search.action';            var windowoption='resizable=yes,height=600,width=800,location=0,menubar=0,scrollbars=1';            var params = { 'param1' : '1','param2' :'2'};                       var form = document.createElement("form");            form.setAttribute("method", "post");            form.setAttribute("action", winURL);   ...

Generate Random file name in Java

You can create a random string for a file name using following code snippet. public static String getRandomString(String fileName) { char fileNameArray[] = fileName.toCharArray(); int fileNameLen = fileNameArray.length; int c = 'A'; int r1 = 0, z=0; StringBuilder pw = new StringBuilder(""); for (int j = 0; j < 25; j++) { r1 = (int) (Math.random() * 4); switch (r1) { case 0: c = '0' + (int) (Math.random() * 9); if (c>'9'){ z = reset(z,fileNameLen); c = fileNameArray[z]; } break; case 1: c = 'a' + (int) (Math.random() * 25); if (c<'a' && c>'z'){ z = reset(z,fileNameLen); c = fileNameArray[z]; } break; case 2: c = 'A' + (int) (Math.random() * 25); if (c<'A' && c>'Z'){ z = reset(z,fileNameLen); c = fileNameArray[z]; } break; } pw.ap...

Tomcat 7: Set context path for your application in tomcat 7

Set context path for your application in tomcat 7 If you want to change context path for your application, you can do by changing {catalina_base}/conf/server.xml file. Suppose, you have deployed your application in tomcat 7,               http://localhost:8080/MyApp You want to set context path to newMyApp, Modify, host element in server.xml under tomcat/conf <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="false"> .... ... . <Context path="/ newMyApp "  docBase="/ MyApp " reloadable="true">  </Context> …  </Host> For detailed information, visit  http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html#A_word_on_Contexts