[solved] url rewrite removing the ;jsessionid= from the url

Splash Forums PrettyFaces Users [solved] url rewrite removing the ;jsessionid= from the url

This topic contains 11 replies, has 4 voices, and was last updated by  Lincoln Baxter III 11 years, 4 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • #17748


    Hi, first of all i would like to say that PF has saved a lot of time and made the jsf rewriting a painless issue (almost :P) for us !

    We have a problem here that is bothering us,

    we are trying to use the following thing

    <rewrite match=”^/foo/(.*)$” substitute=”/bar/$1″ />

    we are trying to rewrite it so that it will remove the whole “;jsession=….” part from the url.

    For example




    Could any one help with the regex or tell us how to do it?

    We have only managed to remove the “;jsessionid” part but not more:/

    Thanks for your time,



    Try this rule to remove JSessionID from inbound URLs – it has not been verified on outbound URLs, but please let us know if you get it to work, or if you can’t, what’s holding you back:

    <rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="301"/>



    Thanks for your reply.

    I could not make it work :( however if i removed the = from the jsessionid then it worked (for url’s without = after the jsessionid)!


    Could you post your solution?

    Could you also post the Before & After URLs? Before rewriting, and after rewriting?

    This will help me figure out what to do :) Thanks!



    Hi again!

    Well this is before and after! here are some of the cases:




    The site can be seen at www aggeliofrenia gr.

    I dont know what i’m doing wrong. I’m not an regex expert! But maybe there is

    something specifc about this jsessionid=.

    (although i red that it can be done with rewriting).

    Thanks again for your time :)



    you might as well simply disable appending of the jsessionid




    we dont have support for Servlet 3.0, tried that :(


    So, enabling this functionality in PrettyFaces actually requires a modification to be made. The JSessionID will always be appended in the URL because the prettyfaces rewritten URL is passed to the container after the rewrite occurs. This means that jsessionid is appended after rewrite rules are processed.

    See related source code in PrettyFacesWrappedResponse

    In effect, you can remove JSessionID from inbound URLs, but with the current configuration, not from links. I’ve been debating this functionality, but it would add a level of complexity that I’m not sure is a good thing.

    Opinions welcome.



    Well, i think that it would be a nice feature! Its all about seo, and making things easier. But i agree that it would make things a bit more complex :)



    Previously I have configured a sun-web.xml for my case:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"
    <!-- Don't add JSESSIONID for resources -->
    <property name="enableURLRewriting" value="false"/>

    But now I’m going for domdorn’s suggestion.


    I looked in to this deeper, and it seems like removing this functionality in PrettyFaces would probably be bad practice.. it’s possible, but not really a great thing to do since it breaks some assumptions that the server makes in order to host websites properly.


    Rewrite rules should now apply with the latest prettyfaces version, and this should also work via prettyfaces now.

    This will remove JSESSIONID from *inbound* requests:

    <rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="301"/>

    Outbound requests will still contain the value until how to properly handle this is determined.

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

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.