Skip to main content

Posts

Showing posts from November, 2010

Learned a Lession

Install Ubuntu in Windows When I had to install Ubuntu for the first time ,what I did was simply install it inside windows using wuby installer. For that moment it seemed the easiest way to done so,but later I was realized how much of troubles it gave for me,while using my duel-boot laptop.According to my requirements I required high capacity in Ubuntu to do programming.But when ubuntu installed inside Windows OS in same partition,the amount of usable space for working in ubuntu is highly reduced.So the performance become highly decreased.Sometimes machine got to stuck. So by my own experience,I want to say if you are going to install ubuntu for a machine in which Windows already installed and going to start programming on ubuntu,always try to install Ubuntu in another seperate partition.It will take more time and feel much more complex during the installation period.But I'll guarantee it will results high performance to carry on your work on Ubuntu in later time.

AJAX-XMLHttpRequest Part3

(Link with the post AJAX-XMLHttpRequest 2 ) Finally a function useHttpResponse need to be written which will establish when the server has completed our request, and do something useful with the data it has returned: function useHttpResponse() { if (http.readyState == 4) { var response = http.responseText; } } Note here that the function checks for a readyState value of 4 - there are various numbered states describing the progress of such a request, but only value of 4 indicates that the request is complete and we can use the returned data. In this case, the information has received as simple text via the responseText property of our XMLHTTPRequest object. Information can, however, be returned as XML ,JSON or as properties of a predefined javascript object. References: http://www.w3.org/TR/XMLHttpRequest/ http://www.ibm.com/developerworks/web/library/wa-ajaxintro...

AJAX-XMLHttpRequest Part2

(Link with the post AJAX-XMLHttpRequest 1) First, need to know how to create an XMLHTTPRequest object. With IE(The way of creating the object depend on the web browser), the request looks like: http=new ActiveXObject("Microsoft XMLHTTP"); whereas in a standards-compliant browser object can be instantiated as: http = new XMLHttpRequest(); Then an event handler which will be called via some event on user's page need to be written and it will handle sending the request for data to the server. In the following example event handler called updateData ,a request of the server is made by using a GET method to an appropriate server-side script.A XMLHTTPRequest object has created and called it http: function updateData(param) { var myurl = [here I insert the URL to my server script]; http.open("GET", myurl , true); //This is to open the connection with the server. ...

AJAX-XMLHttpRequest Part1

I'm totally new to AJAX technology.Since I got an AJAX related task on my job,I had to carry out a research on it and get a clear understanding on it.Following is the knowledge I gained from that research. Before talking about XMLHttpRequest, I'll describe what is AJAX. Ajax (Asynchronous Javascript And XML) is a technique to submit server requests and return information from the server to the user without the necessity of waiting for a page load. An Ajax script makes a request of a server by using the Javascript XMLHTTPRequest object,instead of using a a normal HTTP POST or GET request.XMLHTTPRequest retrieves information from the server in an invisible manner without using a page refresh. (Link with the post AJAX-XMLHttpRequest 2)

Convert an InputStream to XML

For that we can use DocumentBuilder class in java. By using the method parse(InputStream) ; A new DOM Document object will return. InputStream input; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document dc= parser.parse(input); In the above code segment,by using the created Document object,the corresponding XML file for the inputStream can be accessed. References: http://www.w3schools.com/dom/dom_intro.asp http:// download.oracle.com/javase/1.4.2/docs/api/javax/xml/parsers/DocumentBuilder.html

Convert a ByteArrayInputStream to a XML file

InputStream input; OutputStream out = new FileOutputStream("file location"); int read=0; input = registry.get(Path).getContentStream(); byte[] bytes = new byte[1024]; while((read = input.read(bytes))!= -1){ out.write(bytes, 0, read); out.write( '\n' ); } input.close(); out.flush(); out.close(); System.out.println("New file created!");

HTTPRequest

How to retrieve a value for a parameter included in a request? String Url=req.getParameter("url"); //get the value for the parameter url How to set a value for any attribute in a request? req.setAttribute("key", 123); //set the value 123 for the attribute 'key'

JSON-JavaScript Object Notation

JSON is a syntax for passing around objects that contain name/value pairs, arrays and other objects. It is a lightweight text-based open standard designed for human-readable data interchange. And it is language-independent, with parsers available for virtually every programming language.The JSON format is often used for transmitting structured data over a network connection. JSON is primarily used to transmit data between a server and web application, serving as an alternative to XML. JSON Format An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon). The name/value pairs are separated by , (comma). An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma). The following example shows the JSON representation of an object that describes a employee. The object has string fields for first name and last name, a number field fo...