0

I am having trouble passing data to my servlet code from a request placed from action script

Here is how my actionscript code looks

var variables:URLVariables = new URLVariables();
variables.sessionId = sessionId;
variables.userName = userName;
variables.allExtensions = allExtensions;
variables.redirectPath = redirectPath;

var urlRoute:URLRequest = new URLRequest(endPointUrl +"-standalone");
urlRoute.data = variables;
urlRoute.method = URLRequestMethod.POST;
navigateToURL(urlRoute, "_blank");

Java servlet code looks like this

public class StandaloneRedirectServlet extends HttpServlet {

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)  
throws ServletException, IOException 
{

    //All of these are null
    String sessionId = req.getParameter("sessionId");
    String userName = req.getParameter("userName");
    String allExtensions = req.getParameter("allExtensions");
    String redirectPath = req.getParameter("redirectPath");

    //Set cookie

    //Redirect
    resp.sendRedirect("http://www.google.com"); //This would redirect to redirectPath eventually. For testing, I am using google.com
}

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    this.doPost(req,resp);
}

I know for a fact that the URLVariables (sessionId, userName etc) are set to valid values from the action script side. But on the java side, I get all nulls when I extract the parameters. I am clearly not understanding the right way to pass parameters to my server end point and any help is appreciated.

Thank you

user2789284
  • 691
  • 1
  • 8
  • 23
  • Have you tried to POST the values with a plain HTML form, REST client etc.? Just to rule out actionscript. – ptrk Feb 17 '15 at 20:39
  • Yeah. You are right. This is not working even from a form post in html/javascript. I used the function to post data to the same end point from the javascript console and still get nulls - http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit – user2789284 Feb 17 '15 at 20:55
  • Try getParameterMap() then to see if you're getting anything at all. The code looks OK to me, so it must be something funny. http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getParameterMap%28%29 – ptrk Feb 17 '15 at 21:07

0 Answers0