[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 7 years ago.

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

    dimman
    Participant

    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

    /plhrof;jsessionid=747C5927B9060E79A20349109ADCD482

    /plhrofor/test/;jsessionid=747C5927B9060E79A20349109ADCD482

    /plhrofor/test/test2;jsessionid=747C5927B9060E79A20349109ADCD482

    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,

    Dimman

    #19972

    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"/>

    #19973

    dimman
    Participant

    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)!

    #19974

    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!

    #19975

    dimman
    Participant

    Hi again!

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

    http://localhost:9999/aggeliofrenia/aggelies/oles-oi-perifereies/hlektronikes-syskeyes;jsessionid=0BB8F7A4EB6AD2E6770AA7249F4321F6

    and

    http://localhost:9999/aggeliofrenia/aggelies/oles-oi-perifereies/oles-oi-kathgories/anazhthsh/oles/typos-oles/taxinomhsh-kata-hmeromhnia/0;jsessionid=0BB8F7A4EB6AD2E6770AA7249F4321F6

    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 :)

    #19976

    domdorn
    Participant

    you might as well simply disable appending of the jsessionid

    http://dominikdorn.com/2010/03/disabling-jsessionid-url-appending-servlet-3-0/

    #19977

    dimman
    Participant

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

    #19978

    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.

    #19979

    dimman
    Participant

    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 :)

    #19980

    wise_guybg
    Participant

    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"
    "http://www.sun.com/software/dtd/appserver/sun-web-app_3_0-0.dtd">
    <sun-web-app>
    <session-config>
    <session-properties>
    <!-- Don't add JSESSIONID for resources -->
    <property name="enableURLRewriting" value="false"/>
    </session-properties>
    </session-config>
    </sun-web-app>

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

    #19981

    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.

    #19982

    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)

You must be logged in to reply to this topic.

Comments are closed.