remove jsessionid in url

2019-04-08 16:48发布

问题:

I am facing a problem in jsf web application deployed in jetty web-server. When access application in browser, jsessionID is appended in the url. I want to remove it from there. Thanks in advance.

回答1:

Set the org.mortbay.jetty.servlet.SessionURL parameter to none in either the application web.xml or the context configuration.

See the Jetty jsessionId documentation.



回答2:

You can do that by Setting Session Characteristics. Set the context parameter org.eclipse.jetty.servlet.SessionIdPathParameterName to none to disable url rewriting and prevent the jsession id appended to URL.

In web.xml,

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

Or if you are using annotation config instead of web.xml,

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
       servletContext.setInitParameter("org.eclipse.jetty.servlet.SessionIdPathParameterName", "none");
}

Refer: Jetty's Session Management