Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@JB Nizet and @Pointy Thanks for your time and replies. I figured out a solution for my problem. @Pointy I am changing subdomain of user which require a redirect but also i don't want to loose post parameters in that request. I hope now it make sense.</p> <p>Here what I did (in Steps): </p> <ul> <li>First I figured when i need to do redirect and need to save post parameter.</li> <li>Save all the post data in session (temporally). </li> <li>If i have any temporally post value in session I put it in new request and removes the post value from session.</li> </ul> <p>Code: For setting post parameter in session:</p> <pre><code>resolution = new RedirectResolution(reponseUrl); Iterator&lt;Map.Entry&lt;String, String[]&gt;&gt; requestParamter = ctx.getRequest().getParameterMap().entrySet().iterator(); List&lt;IdName&gt; requestParams = new ArrayList&lt;IdName&gt;(); while(requestParamter.hasNext()){ IdName param = new IdName(); Map.Entry&lt;String, String[]&gt; entry = requestParamter.next(); param.setName(entry.getKey()); param.setParameterValues(entry.getValue()); log.trace("intercept - Adding Key: {} with value: {} to redirect request parameter.", entry.getKey(), entry.toString() ); requestParams.add(param); } ctx.setRedirectRequestParameter(requestParams); </code></pre> <p>For getting it back:</p> <pre><code>if(ctx.getRedirectRequestParameter() != null &amp;&amp; !ctx.getRedirectRequestParameter().isEmpty()){ //Removes parameter which are already in request from redirect request parameter. Map&lt;String, String[]&gt; additionalParams = new TreeMap&lt;String, String[]&gt;(); Map requestParameterMap = ctx.getRequest().getParameterMap(); ListIterator&lt;IdName&gt; oldRequestParams = ctx.getRedirectRequestParameter().listIterator(); while(oldRequestParams.hasNext()){ IdName oldRequestParam = oldRequestParams.next(); log.trace("Lopping requestparameter key: {} ", oldRequestParam.getName() ); if (!requestParameterMap.containsValue(oldRequestParam.getName())) { additionalParams.put(oldRequestParam.getName(), oldRequestParam.getParameterValues()); } } HttpServletRequest newRequest = new MyperksHttpServletRequestWrapper(ctx.getRequest(), additionalParams); ctx.setRequest(newRequest); ctx.setRedirectRequestParameter(null); } </code></pre> <p>I have also created a wrapper class which adds new parameter to request which create a new request wrapper that will merge additional parameters into the request object without prematurely reading parameters from the original request. For deatil about this class kindly follow the link: <a href="http://ocpsoft.org/opensource/how-to-safely-add-modify-servlet-request-parameter-values/" rel="nofollow">PrettyFaceRequestWrapper</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload