Tuesday, 22 November 2011

Sun City 'Jodhpur' Trip

This was a trip planned 3 months back as our colleague usain was to get married in Jodhpur. So, we all ALU colleagues, a total group of 10 (& 5 lovely kids) decided to attend the marriage & get the feel of the Sun City Jodhpur.

We boarded the train Mandoor Express on Friday eve from Delhi-NCR; it was fun especially for gupta ji & rajneet as both were lucky enough (as usual) to get attractive neighbors in the train. Now pls. don’t ask how much attractive ;). Thanks to sudhir & gupta ji that we got some home made delicious dinner in the train (bachelors are always thankful if they get homemade & free food on train).

The start got more interesting with playing cards from rajesh & yes Rs 60 was complete paisa wasool. Though our neighbor in train must have cursed that night for the halla gulla which we created but then that's how we are.....ha ha ha.

 Special attraction of that night was the guest appearance of the 'groom' usain at midnight on Alwar station & no need to mention that he came just to meet one person & that person also delighted & surprised Umesh with his new look (similar to usain's ;)).Proper DDLJ ka train scene tha, sarso ke khetto wala to ho hi chuka tha. Even the compartment's attendants became the part of that historic meet.


So after that eventful night came Jodhpur in the morning, opposite to our expectations it wasn’t cold & we realized that half of our luggage would be of no use. As we got put of the station we got a feel of the city, its much of a similar to small cities in India with a ethnic Rajasthani touch, not only the forts but common houses in the city were made up of castle stone & looked royal. The auto's in the city are spacious but with a strict policy of 3 only (though later we realized that this is only for the tourists like us).


Moving forward we went to hotel 'Mapple Abhay', the reception area was occupied with foreigners, the rooms were great with mine & Mohit's being biggest of the 5 we got. Swimming pool was a disaster but restaurant was real good with yummy food.

On first day we moved towards the Mehrangarh fort, it was at a good height which gave sweatings to guptaji (actually bhabhi ji gave him the responsibility of sara which he successfully managed for full 10 minutes ;)).We decided to hire a guide but guide turned out to be full Thaakela types. If i would have known this, I would have studied & explained much more in detail....but the visit was good with a normal discussion that from where was the King of fort originally from ? Haryana or UP...the discussion still continues..

No doubt from the top of the fort the city looked amazing & sudhir clicked some real good pics. Our other official photographer gupta ji decided not to join us to the top for obvious reasons but he also had a good time listening to some wonderful folk music.




Next day we went for a lake view, I agree with rajneet/gumber that ponds in haryana are far much better than that lake but still we thought ki jab aa hi gaye hain to 1 boat ride to banti hain, so we all (except rajneet & gumber who were still dreaming of pond's of Haryana) took the ride. There is nothing much to say about that pond visit except a few well narrated ghost stories from sanvi....



After that we went to Umaid bhawan palace, palace gave us an insight of the royalty & immense wealth which they had. The King from the pics displayed looked ordinary like a common indian but again was born in a royal family & was a King. His fleet of vintage cars was at display & Mercedes looked so ordinary. 


Later we went for a desert safari, which was around 65 Km away from Jodhpur, there we stayed in Swiss tents for a while & later went for the camel ride. Camel ride was real fun & so was climbing the sand dunes, the sun set looked really amazing from the top......it was so quite & peaceful out there. There were small boys who were riding those Camels, they walk 4-5 km daily to go to school & later ride camels so that make their livings...that reminded me of the king ...what an irony...







In the night we had a Rajasthani folk dance & music show beside our dinner, the dancer & singers were really great & we all had a memorable time there. The dinner was also proper authentic rajasthani food. 






Next day was the marriage day, the first half was in the hotel & next at usain's place, we spent most of our time playing cards & pulling legs :). At the marriage, usain looked more like 'Jadugar Pasha' with a magic stick :). Jokes apart, he was looking like a kanwar-sa, actually it was the rajasthani groom’s dress which made him looked so different. The groom & bride looked great together.






With the marriage, the trip also ended & we boarded the train back to Delhi.







 Apart from this a special mention of those 5 cute & naughty kids is required. They actually made this trip fun filled.














Note: My sympathy is there with my those colleagues who could not manage to join us on this trip.

Wednesday, 16 November 2011

Get Image using Ajax apart from Text/XML response

Hi All,


When we use Ajax then we can only get Text/XML response using the url.
With the help of the below procedure we can also get the image using ajax.

The Client side programming is something like:

<html>
<head>
<script>
      function createGraphs(){
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    var imageResponse = xmlhttp.responseText;
                    changeImage(imageResponse);
                }
            }

        xmlhttp.open("POST","GetImageResponse.do",true);
            xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlhttp.setRequestHeader("Content-length", params.length);
            xmlhttp.setRequestHeader("Connection", "close");
            xmlhttp.send(params);
            xmlhttp.send();
        }

     function changeImage(type,imageResponse){
            document.getElementById("graph").src = "data:image/png;base64,"+imageResponse;
        }
</script>
</head>
<body>
    <img alt = "graph" id = "graph" name="linechart" src="" />
    <input type="button" value="get Image" onclick="createGraphs()"/>
</body>
</html>

On click of the button a ajax response is sent to the server & receives text type response which is added to the source of the image tag as
document.getElementById("graph").src = "data:image/png;base64,"+imageResponse;




The Server side programming is something like:


 //Struts Action Method
 public ActionForward execute (final ActionMapping mapping,
                                  final ActionForm form,
                                  final HttpServletRequest request,
                                  final HttpServletResponse response) throws Exception {
        final byte[] chartbytes = this.getBytesFromFile (new File ("C:/Image.png"));
        final BufferedInputStream buf = null;
        ServletOutputStream myOut = null;

        try {
            myOut = response.getOutputStream ();
            // set response headers
            response.setContentType ("application/png");

            final String filename = "graph.png";
            (response).addHeader ("Content-Disposition", "attachment; filename=" + filename);
            response.setContentLength (chartbytes.length);
            myOut.write (chartbytes);
        } catch (final IOException e) {
            System.err.println ("Exception::" + e.getMessage ());
        } finally {
            if (myOut != null) {
                myOut.close ();
            }
            if (buf != null) {
                buf.close ();
            }
        }
        return null;
    }

    // Returns the contents of the file in a byte array.
    public byte[] getBytesFromFile (final File file) throws IOException {
        final InputStream is = new FileInputStream (file);

        // Get the size of the file
        final long length = file.length ();

        // You cannot create an array using a long type.
        // It needs to be an int type.
        // Before converting to an int type, check
        // to ensure that file is not larger than Integer.MAX_VALUE.
        if (length > Integer.MAX_VALUE) {
            // File is too large
        }

        // Create the byte array to hold the data
        final byte[] bytes = new byte[(int) length];

        // Read in the bytes
        int offset = 0;
        int numRead = 0;
        while ((offset < bytes.length) && ((numRead = is.read (bytes, offset, bytes.length - offset)) >= 0)) {
            offset += numRead;
        }

        // Ensure all the bytes have been read in
        if (offset < bytes.length) {
            throw new IOException ("Could not completely read file " + file.getName ());
        }

        // Close the input stream and return bytes
        is.close ();
        return bytes;
    }

In server side the image if converted to Array of bytes & sent to client
So, in this way one can tranfer the images to client side using ajax




Regards,
Pankaj Khattar




Advertisement-Are you ready to get most of your iPAD !!!