Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:00:04+00:00 2026-06-05T20:00:04+00:00

I am facing problem in intercepting and changing request url to link it with

  • 0

I am facing problem in intercepting and changing request url to link it with correct URL.
I am using stripes framework, and want to redirect user to their correct subdomain.
For eg. if user belongs to abc.sitename.com and request came from xyz.sitename.com he should be redirected to abc.sitename.com with all request post.
For getparameter i have done this by simply getting request url and request query and redirecting user from custom intercept class before lifecycle resolution execution. But all post parameter are flushed as it is redirect.
Another solution was to forward resolution, but it can take user within context and i need to override it as:

resolution = new OnwardResolution<ForwardResolution>(reponseUrl) {
                    @Override
                    public void execute(HttpServletRequest request,
                            HttpServletResponse response) throws Exception {
                        request = ctx.getRequest();
                        response = ctx.getResponse();
                        String path = reponseUrl; //getUrl(request.getLocale());
                        // Set event name as a request attribute
                        String oldEvent = (String) request.getAttribute(StripesConstants.REQ_ATTR_EVENT_NAME);
                        //request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, event);
                        log.info("check: {}", path);
                        // Revert event name to its original value
                        request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, oldEvent);
                        // Figure out if we're inside an include, and use an include instead of a forward
                        RequestDispatcher dispatcher = request.getRequestDispatcher(path);
                        //request.getRequestDispatcher(path).forward(request, response);
                        dispatcher.forward(request, response);

                    }
                };

But it is calling in application context path, whereas it should call the complete url.
Another solution, If I use redirect resolution and set includerequest parameter true will do the job, but put all request parameter into url which makes it unacceptable.

Request url should be changed before resolution executuion as after it it will be of no use, I have tried it. is there any way to set request url in HTTPServeletRequest.

I have also tried to intercept during ActionBeanResolution, It is the best place to do such activity. My main problem is POST parameters. I can not redirect (as they get flushed or if use include reuest parameter they are visible in URL). Forward resolution on forward in context. If there is a way to forward it to new URL it will do the job.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:00:07+00:00Added an answer on June 5, 2026 at 8:00 pm

    @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.

    Here what I did (in Steps):

    • First I figured when i need to do redirect and need to save post parameter.
    • Save all the post data in session (temporally).
    • If i have any temporally post value in session I put it in new request and removes the post
      value from session.

    Code:
    For setting post parameter in session:

    resolution = new RedirectResolution(reponseUrl);
                Iterator<Map.Entry<String, String[]>> requestParamter = ctx.getRequest().getParameterMap().entrySet().iterator();
                List<IdName> requestParams = new ArrayList<IdName>();
                while(requestParamter.hasNext()){
                    IdName param = new IdName();
                    Map.Entry<String, String[]> 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);
    

    For getting it back:

    if(ctx.getRedirectRequestParameter() != null && !ctx.getRedirectRequestParameter().isEmpty()){
                    //Removes parameter which are already in request from redirect request parameter.
                    Map<String, String[]> additionalParams = new TreeMap<String, String[]>();
                    Map requestParameterMap = ctx.getRequest().getParameterMap();
                    ListIterator<IdName> 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);
                }
    

    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: PrettyFaceRequestWrapper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Facing problem with every fetch i want to make using EF Query model.Place here
Iam facing problem in understanding and converting a matlab code into opencv. I want
I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using
I am facing problem in getting Facebook data I am using Facebook SDK for
I am facing problem when url is redirected. I set webviewclient and It is
I am facing problem for reading xml file using javascript. It works fine in
I am facing problem where after changing host name my application is failing. In
facing problem in searching and displaying the list using text watcher. it is a
I am facing problem when comparing 2 strings values using C:When tag I am
I am facing problem while GWT compilation. I am using ANT build file in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.