Prettyfaces or rewrite integration with jersey

Splash Forums PrettyFaces Users Prettyfaces or rewrite integration with jersey

This topic contains 4 replies, has 2 voices, and was last updated by  jlerbsc 6 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #27330


    I have a service implemented with jersey and after some work i would like to redirect the user on a JSF view with a prettyfaces pattern like this “/user/activation/#{ref: controller.ref}”. Could you give me a tip to implement this case? For the moment i am using prettyfaces 3.3.3 but i can migrate to rewrite!
    I tried unsuccessfully to implement this solution ( In the last attempt the target url generated was /user/activation/123456 and it seems that the context part of the webapp is omitted. I would like something like /app_context/user/activation/123456. Thanks in advance for your help.


    If the last attempt worked fine and was just missing the context path, you could replace



    response.sendRedirect(request.getContextPath() + targetURL);

    to get it working.



    Thanks for your response but I don’t understand why we have no problem within JSF/Primefaces and i have another behavior in jersey context.


    What “other behavior in jersey context” do you mean? The missing context path?

    If you want to redirect to a PrettyFaces URL, you have to do two things:

    First you need to build the target URL. You can either use PrettyURLBuilder or simple string concatenation for this. Using PrettyURLBuilder will require more code, but in this case you can change the URL pattern at a single place. Using string concatenation is usually much simpler, but you have to take care that the URL structure matches the one from the mapping.

    When you have the target URL, you will have to send the redirect. You can use HttpServletContext#sendRedirect() for this. This works fine in most of the cases. Especially in Servlets. If you want to redirect from a JAX-RS resource, you can also use Response#temporaryRedirect() instead, which is more in line with the JAX-RS programming model.

    If you use an absolute URL (which is always the case if you are using PrettyURLBuilder) you will have to make sure to add the context path of the application. Not sure how Response#temporaryRedirect() handles this though.

    Hope this helps.



    Thank. I will follow your advice
    response.sendRedirect(request.getContextPath() + targetURL);
    and i will also try Response#temporaryRedirect() to see if jersey will build correctly the final url .

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.