是否可以在tomcat servlet中禁用jsessionid? [英] Is it possible to disable jsessionid in tomcat servlet?

查看:165
本文介绍了是否可以在tomcat servlet中禁用jsessionid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在tomcat的url中关闭jsessionid? jsessionid似乎对搜索引擎不太友好。

Is it possible to turnoff jsessionid in the url in tomcat? the jsessionid seems not too search engine friendly.

推荐答案

您可以使用此过滤器禁用搜索引擎,但我建议将其用于所有回复,因为它比不友好的搜索引擎更糟糕。它公开了可用于某些安全漏洞的会话ID(更多信息)。

You can disable for just search engines using this filter, but I'd advise using it for all responses as it's worse than just search engine unfriendly. It exposes the session ID which can be used for certain security exploits (more info).

Tomcat 6(6.0.30之前)

您可以使用 tuckey重写过滤器

示例配置

<outbound-rule encodefirst="true">
  <name>Strip URL Session ID's</name>
  <from>^(.*?)(?:\;jsessionid=[^\?#]*)?(\?[^#]*)?(#.*)?$</from>
  <to>$1$2$3</to>
</outbound-rule>

Tomcat 6(6.0.30及以后)

您可以使用 disableURLRewriting 在上下文配置中禁用此行为。

You can use disableURLRewriting in the context configuration to disable this behaviour.

Tomcat 7和Tomcat 8

Tomcat 7以后您可以添加在会话配置中跟随。

From Tomcat 7 onwards you can add the following in the session config.

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

这篇关于是否可以在tomcat servlet中禁用jsessionid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆