Posts

database logic

brief : ALTER TABLE A       ADD CONSTRAINT id       PRIMARY KEY (id) ALTER TABLE B ADD COLUMN a_id VARCHAR //add fkey  in B as additional cols ALTER TABLE B ADD COLUMN a_id int //now create the fkey ref to agent table on address table alter table B ADD Foreign key(a_id) references A(id); // To obtain the generated constraint name of a table SHOW CREATE TABLE B; ALTER TABLE B DROP FOREIGN KEY b _ibfk_1; //to disable fkey checks. SET foreign_key_checks = 0/1;

Angular 2 & 2+

how to fixe cors problen in angular 6. -------------------------------------------- e.g. -@CrossOrigin(origins = "http://localhost:4200/") -at @configuration class  @Bean     public CorsFilter corsFilter() {         UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();         CorsConfiguration config = new CorsConfiguration();         config.setAllowCredentials(true);         config.addAllowedOrigin("*");         config.addAllowedHeader("*");         config.addAllowedMethod("OPTIONS");         config.addAllowedMethod("GET");         config.addAllowedMethod("POST");         config.addAllowedMethod("PUT");         config.addAllowedMethod("DELETE");         source.registerCorsConfiguration("/**", config);         return new CorsFilter(source);     } //Api call-> http api call 1.first HttpClient i

Spring-boot

advantage : 1. production ready application  2. complex configuartion is reduced  3. pom.xml -all dependency define via ths file . 4. used for standalone and web apps . 5. used for microservices -*** 6. @EnableAutoConfiguration  automatically configures the Spring application based on its included jar files  note:   6.1-  Auto-configuration is usually applied based on the classpath and the defined beans      6.2- @EnableAutoConfiguration has a exclude attribute to disable an auto-configuration explicitly otherwise we can simply exclude it from the pom.xml, for example if we donot want Spring to configure the tomcat then exclude spring-bootstarter-tomcat from spring-boot-starter-web.    eg. like as follwing : <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.apache.tomcat</groupId> &l

Looping json array into javascript and jsp

Suppose i have json array .now i want to loop all object values in javascript Jsonarray is "jsonarr" I.e. For (int i=0;i<jsonarr.length;i++) { Var v=jsonarr[i]; Then v.name; }

How to pass dropdown selected values(list) as a parameter via Ajax to controller

in js file :     var sid= document.getElementById('mySelect'); var setitem= ""; for(i=0;i<sid.options.length;i++){       setitem= setitem+ sid.options[i].value + ","; } // Remove the last splitter setitem= setitem.substr(0,setitem.length-1); alert(setitem); Then pass the setitem to your data parameter in jQuery's AJAX. data: {        list: setitem,         }, while send convert the object type contentType: 'application/json; charset=utf-8',  data :JSON.parse(setitem) ; using parse method. or use JSON.stringify( setitem); Note: while data sending and receiving we should take care what kind of deta we are sending and accorind to that we should take care and make sure that same data type is defined 

How spring flow

Web.xml file is Written .will be load first and inside web.xml file we have one default file  will we load  Inside at least one servlet should be . Whatever the bean we are writing inside this file will be loaded at server startup or first User Request. i.e Connection beans ,database related beans,tx beans ..etc. For Spring Mvc dispatcherServlet have used -called front controller its take care all the user request and further process .How http request response will be process all stuff will handled by DS Servlet . Flow: Step  1 : first user request will be take by DispatcherServlet. Step  2 :  DS    will call and take the help of  HandlerMapping  and get to know the  Controller  class . Step  3 : And then controller will process the request by executing appropriate methods and return back the View using ModelAndView Step 4: Actual view will populated and Step  5 : Finally  DS  will pass the  Model  object to the  View  page to display the View with result on UI. Not

Ajax calling to controller

Ajax calling to controller method Sample Code: Desc: 1.>onbutton click  id = 'call' click, ajax() will call to states() method that defined in controller class . and getting response into 'Result' variable object and putting response into divID of <div> tag into body . <script type="text/javascript">         $(document).ready(function() {             $('#call').click(function ()   //'call is an ID of UI comp';               {                 $.ajax({                     type: "post",                     url: "./states", //Controller method                     data: “cname”:india,                     success: function(Result){                                  $('#divID).append(Result);                     }                 });             });   });     </script>     <title>Jsp file</title> </head> <body>     input:<input id="cname" type=&qu