Struts 1 redirect from action to action with parameters as POST request

16,401

You can't, it is not a Struts problem. It is how HTTP is designed. When a browser is redirected, it perform a GET request. You cannot ask the browser to do a POST instead. The only way would be to add some Javascript to send the request.

Or you can also ask Struts to do an internal redirection but it will be hidden to the client and the url will not change.

Share:
16,401
rpandidurai
Author by

rpandidurai

Updated on June 05, 2022

Comments

  • rpandidurai
    rpandidurai almost 2 years

    now am trying to redirect to action class from action class with some parameters in my Struts 1.3 web application, here is my code

    ActionRedirect redirect = new ActionRedirect(mapping.findForward(forwardPage));
    redirect.addParameter("method", forwardPage);   
    redirect.addParameter("username", "user");
    redirect.addParameter("password", "PWD");
    redirect.addParameter("forwardPage", "success");        
    return redirect;
    

    it's working fine, but all parameters are showed in address bar, how can i redirect it as POST request parameter(hide parameters)

  • rpandidurai
    rpandidurai almost 11 years
    thank u gma, how internal redirection could do? can u give some idea plz?
  • gma
    gma almost 11 years
    with a simple return actionMapping.findForward(...) in your action, by default struts perform internal redirection, if you want an explicit (by browser) redirection you have to put redirect=true in your forward mapping.