Thursday, February 5, 2009

1) Ajax made Simple

Ajax in Simple steps.............ENJOYYYYYYYYY

Basically there are 3 things to be understood in Ajax

1) we have a request state that tells the request state after its being sent from AJAX/javascript code

State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete

2) A function is being called at every state of request .

xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
// Get the data from the server's response
}
}

4) Get the data from the server's response

xmlHttp.responseText

Now Before all these we need 2 things more

1) get XMLHttpRequest object (its an ActiveXObject ).

2) send the request using
xmlHttp.open("GET","time.asp",true);
xmlHttp.send(null);

2) JOB SCHEDULING USING QUARTZ IN JAVA

An easy example for JOB scheduling

class 1 MainApplication :-




import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import org.apache.catalina.util.URLEncoder;


class MainApplication {

public static void main(String[] args) {
Timer timer = new Timer();
Calendar date = Calendar.getInstance();
date.set(
Calendar.DAY_OF_WEEK,
Calendar.WEDNESDAY
);
date.set(Calendar.HOUR, 5);
date.set(Calendar.MINUTE,0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);

// Schedule to run every Sunday in midnight
timer.schedule(
new ReportGenerator(),
date.getTime(),
1000 * 60 * 60 * 24 * 7
);

}
}


class 2 ReportGenerator :-



import java.util.TimerTask;


public class ReportGenerator extends TimerTask {

public void run() {
System.out.println("This is VIKASSSSSSSSSSSSSSSSSSSSSSSS:: ");
//TODO generate report
}

}

---------------------------------------------------------------