For the first question, see this SO answer .
In the second question, I would say that you are missing a prefix for your parameters.
try changing your ajax call (I only change the fields that you specify in the serveResource method that gets null)
$.ajax({ url :addToDo, data: { "todo":todo, "<portlet:namespace />adv_name":adv_name, "mediatype":mediatype, "<portlet:namespace />keywords":keywords, "<portlet:namespace />adv_url":adv_url, "fileUpload":fileUpload, "CMD":"addToDo" }, type: "GET", timeout: 20000, dataType: "text", success: function(data) { alert(data); //when i alert this data..its always null } });
and necessarily
<%@ taglib prefix="portlet" uri="http://java.sun.com/portlet" %>
at the top of your jsp.
Also note that in your serveResource method you have
advertise_name = uploadReq.getParameter("advertise_name");
but "adv_url":adv_url, sending "adv_url":adv_url, pay attention to the names.
One more note: you use GET instead of POST.
Another thing to keep in mind is that downloading files using ajax is not supported in all browsers. For a list of supported browsers, see this .
source share