Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of ;jsessionid=xxx path parameter in URL when using h:button

I'm using OmniFaces FullAjaxExceptionHandler in Tomcat7 and JSF 2.1 to handle the ViewExpiredException. I've setup the same error pages as OmniFaces showcase. Look here for error pages and here for template.

It works fine. When the session is expired, then I end up in expired.xhtml error page. However, when I click the below link in the error page,

 <p><a href="#{requestScope['javax.servlet.error.request_uri']}">Back to initial page.</a></p>

then I get the following exception:

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean 

This is not a big problem. I need a button that points the user to the home page anyway. So I replaced it by the below button:

<h:button value="Home" outcome="logout" />

along with this navigation case:

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>logout</from-outcome>
        <to-view-id>/stdPortal/index.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

The navigation took me to the correct page, however the session ID appears in the URL:

https://localhost/stdPortal/index.xhtml;jsessionid=B68784B4ED8882A6575A2EE4012AF1B5

I don't want this. How do I get rid of it? I want the URL to be like:

https://localhost/stdPortal/index.xhtml
like image 935
user1594895 Avatar asked Jun 27 '13 15:06

user1594895


1 Answers

You can get rid of jsessionid path fragment in URL by adding the following to web.xml:

<session-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

It basically disables URL-rewriting.

like image 172
BalusC Avatar answered Nov 10 '22 04:11

BalusC