0

So far I have tried two approaches:
-1. Add to web.xml:

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

-2. Using pretty faces, add to pretty-config.xml:

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

-3. Jetty specific. Add to web.xml:

<context-param>
    <param-name>org.eclipse.jetty.servlet.SessionIdPathParameterName</param-name>
    <param-value>none</param-value>
</context-param>

Nothing helps. Also I cannot understand, what the difference between "#.{jsessionid}" and "jsessionid={jsessionid}" formats (where {jsessionid} is some hash-looking string )?

edit1:
It looks like fragment-id. What is he doing on all my URLs?

alehro
  • 2,198
  • 2
  • 25
  • 41

2 Answers2

1

In addition to what alehro said, Rewrite is probably a better fit for what you are trying to do by removing the session id from the URL and other such custom tasks. The configuration is much more declarative and powerful, but also a bit more verbose.

Here is how you would do the same thing using //Rewrite.

@Override
public Configuration getConfiguration(final ServletContext context)
{
   return ConfigurationBuilder.begin()
      .addRule()
        .when(Direction.isInbound()
          .and(URL.matches("{p}{sessionID}{s}")))
        .perform(Redirect.temporary("{p}{s}"))
        .where("sessionID").matches("#\\.\\w+");
}      

URL parameters default to matching .* so additional configuration is not needed for the prefix and suffix (p) and (s).

Lincoln
  • 3,151
  • 17
  • 22
  • Hi @Lincoln. Is it OK to put `.where()` after `.perform()`? – Arash Jan 04 '22 at 18:48
  • Yes, the API is very strict and order is enforced for you by the types. If it compiles in that order, it works :) – Lincoln Jan 05 '22 at 02:26
  • 1
    The `where()` clause is essentially a configuration of parameters that appear in the rule. – Lincoln Jan 05 '22 at 02:36
  • Thanks for your reply @Lincoln. But when i use your code, i get *cannot find symbol: method where(String)*. When i look at `matches()` method, i see that it returns a `URL` and this abstract hasn't [`where()`](https://www.ocpsoft.org/docs/rewrite-api/2.0.12.Final/org/ocpsoft/rewrite/config/ConfigurationRuleBuilder.html#where(java.lang.String)) method and this method belongs to `ConfigurationRuleBuilder`. Am i mistaken? (And you have extra right parenthesis in the `where()` line). – Arash Jan 05 '22 at 06:16
  • Apologies. It looks like my example code was from a very old version of Rewrite. I fixed it in the original answer! The code should work now. Thanks for asking. Hah! – Lincoln Jan 05 '22 at 15:36
  • You're welcome and thank you for sharing your knowledge. – Arash Jan 06 '22 at 15:48
-1

This hash is not jsessionid. It is appended by addthis tracking. To disable it use:

<script type="text/javascript">
var addthis_config = {
"data_track_addressbar" : false
};
</script>

I don't know, may be it is better to delete the question, as it's kind of stupid.

alehro
  • 2,198
  • 2
  • 25
  • 41