Posts

Showing posts from September, 2016

Ant Build File Creation in Java Using Apache Ant

How to create apache ant build file in project If you are using Eclipse  open the eclipse right click then select Export and select "Ant Build File" then after that select your project where you want to create build file then finish   So it will create build.xml for us . the minimal code to create jar using apache ant build is <?xml version="1.0" encoding="UTF-8"?> <project name="Example" default="makejar" basedir=".">       <target name ="makejar" description="Jar File Creation">     <jar jarfile="Test.jar" includes="*.class" basedir="bin"/>       <echo>******** Jars Files Create Inside Project ********** </echo>   </target> </project>

Class Array JSON Creation in Java

How to create Class level Array and dynamic generate JSON  using Jackson API package com.test.rest; import java.lang.reflect.Array; import com.bean.Animal; import com.bean.Employee; import com.bean.Student; import com.fasterxml.jackson.databind.ObjectMapper; /**  *  * @author anand  *  */ public class JsonUtility {     public ObjectMapper mapper;     public String jsonString;     /*      * This method will Used to Convert ClassObject to JSON  and      * return as a form of JSON as a String      */             public String ConvetObjectArrayToJSON(Object [] array){              mapper = new ObjectMapper();         String jsonArray=null;         System.out.println(array[i]);         try{         for(int i=0;i<array.length;i++){             System.out.println(array[i].getClass());                         jsonString = mapper.writeValueAsString(array[i]);             jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(array[i]);  

Rest API Post Example With Client in Java

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ package com.rest; /**  *  * @author ananddw  */ public class Accounts {         String accountid;     String accountname;     String accountholdername;     String accountholderlocation;     public String getAccountid() {         return accountid;     }     public void setAccountid(String accountid) {         this.accountid = accountid;     }     public String getAccountname() {         return accountname;     }     public void setAccountname(String accountname) {         this.accountname = accountname;     }     public String getAccountholdername() {         return accountholdername;     }     public void setAccountholdername(String accountholdername) {         this.accountholdername = accountholdername;     }     public String getAccountholderlocation() {     

Rest API Example in java

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ package com.test; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /**  *  * @author Admin  */ @XmlRootElement(name = "registration") public class StudentRegistration {     String name;     int roolnumber;     String location;     @XmlElement     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     @XmlElement     public String getLocation() {         return location;     }     public int getRoolnumber() {         return roolnumber;     }     @XmlAttribute     public void setRoolnumber(int roolnumber) {         this.roolnumber = roolnumber;     }     public void setLocation(String loca

How to disable back button after Login in Java

Here is the simple programme when you login with your application it will disable the back button in browser index.jsp <%--     Document   : index     Created on : Sep 6, 2016, 1:17:40 PM     Author     : ananddw --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html>     <head>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">         <title>Login Page </title>     </head>     <body>         <form action="sucess.jsp" method="post">         <table>             <tr>                 <td>UserName</td>                 <td><input type="text" name="uname" id="uname"/></td>             </tr>                         <tr>                 <td>Password</td>                 <td><input type="password" na