Java Code Examples for javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromURL()

The following are Jave code examples for showing how to use isRequestedSessionIdFromURL() of the javax.servlet.http.HttpServletRequest class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: oscm   File: DisableUrlSessionFilter.java   Source Code and License Vote up 6 votes
@Override
public void doFilter(ServletRequest req, ServletResponse res,
        FilterChain chain) throws IOException, ServletException {

    if (!(req instanceof HttpServletRequest)) {
        chain.doFilter(req, res);
        return;
    }

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    if (hasToBeFiltered(request) && request.isRequestedSessionIdFromURL()) {
        String url = request
                .getRequestURL()
                .append(request.getQueryString() != null ? "?"
                        + request.getQueryString() : "").toString();
        response.setHeader("Location", url);
        response.sendError(HttpServletResponse.SC_MOVED_PERMANENTLY);
        return;
    }
    chain.doFilter(req, res);
}