YUI file upload with jsp backend

For last two weeks I was working on some user interface logic and happened to use Yahoo UI library (YUI). The task was to upload an image using Ajax. Since I was new to YUI, I was looking here and there over the net for some references. There were some good ones but thats for PHP back-ends, but mine was a jsp back-end and i didn’t know how to read the object thrown out from the YUI side.

with some more digging I came across nice file handling library in Apache commons (Commons File Upload) and took use of it to do the task. the code is as follows.



YUI File UploadS
http://[PATH_TO_YUI]/yahoo-dom-event/yahoo-dom-event.js
http://[PATH_TO_YUI]/connection/connection-min.js

function init(){
  var onUploadButtonClick = function(e){
    //the second argument of setForm is crucial,
    //which tells Connection Manager this is a file upload form
    YAHOO.util.Connect.setForm('testForm', true);

    var uploadHandler = {
      upload: function(o) {
        alert(o.responseText);
      }
    };
  YAHOO.util.Connect.asyncRequest('POST', 'upload.php', uploadHandler);
  };
  YAHOO.util.Event.on('uploadButton', 'click', onUploadButtonClick);
}

YAHOO.util.Event.on(window, 'load', init);














I took the above code segment directly from a YUI file upload tutorial hence the credit goes to the author. The jsp back-end using apache commons file upload is as follows.
Continue reading YUI file upload with jsp backend

Advertisement

I’m living the dream

Hi folks, Its been awhile, huh almost 5 months since my last post. I was so darn busy with university finals, my thesis and some extra curricular activities ;). So yeah its about time to blog again. In few of my older posts i have written few things about SOA (little things i know), UDDI, Web Services and about the ESB concept. I did my bachelor’s thesis in the area of SOA, ( BACKBONE – A Service Oriented Architecture for Public Infrastructure and Service Governance) proposing a SOA reference architecture for maturing governments. For the past nine months of time I’ve been playing with technologies such as Axis 2, Apache CXF, WSIT/Metro, WSO2 ESB, JSF, Spring, Hibernate etc. etc. (All those J2EE stuff 🙂 )

While I was working on my prototype, composing the services, developing UIs to consume them, connecting the two ends with the WSO2 ESB, resources like IBM library, IEEE explore, ACM library and most importantly WSO2 Oxygen Tank helped me immensely. I was fascinated by the papers and materials offered by WSO2 OT and IBM library for no cost. So Thanks to them I got my thesis done with caliber.

As for any one in their final year of university I my self was looking for a great starting point for my career. I was looking for some deference, not the ordinary software development which exists in many software houses. I was looking for some challenge, where I can explore new things, do research and importantly be part of a great community. For me that starting point was WSO2 (The Open Source SOA Company), and frankly it was a dream come true 🙂

Yeah I am living the dream 🙂

wso2 logo