Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8132251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:18:09+00:00 2026-06-06T09:18:09+00:00

Before I understood that Google cared little for JSessionID, I allowed URL rewriting (the

  • 0

Before I understood that Google cared little for JSessionID, I allowed URL rewriting (the default Tomcat behavior) in my Facelets application. For those that don’t know already, Google does not like this with regards to SEO (the session ID on your URL) and I since have included the following in web.xml to rectify this:

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

The problem is that I have many 500 errors from outdated links that are hurting my SEO because of sites referencing outdated links with these jsession ID’s e.g,:

http://thejarbar.org/views/tutorials/linux/Netbeans-    
Install.xhtml;jsessionid=8D0EF52E48E8BB8BF8A4D7E33F831EFF

I have fixed several errors with pages names with html or xhtml suffixes easily, by creating pages that redirect to updated links, but the problem I have is that I can’t create a file name with a session id suffix as this won’t be served by Tomcat.

Redirecting a dead HTML link is as simple as creating a plain (X)HTML page in the relevant directory and including a meta tag as follows (example):

  • Dead link points to .../Maven-Setup.xhtml
  • Create a replacement Maven-Setup.xhtml in referenced location
  • In the replacement I simply add <meta http-equiv="REFRESH" content="0;url=http://thejarbar.org/views/tutorials/linux/Maven-
    Setup-Tutorial-for-Linux-with-the-Jar-Bar-and-Yucca-Nel.xhtml"></meta>

How can I redirect request based on outdated urls with session ID’s? I would obviously favor keeping these links as they may (or may not) be bringing traffic to my site and hence why I want to redirect.

Update I have created a redirect.jsp with the intention of mapping a url-pattern in web.xml to forward all incomming jsessionid requests to my new ‘no jsession’ site:

<servlet>
    <servlet-name>redirect</servlet-name>
        <jsp-file>/redirect.jsp</jsp-file>
    </servlet>

    <servlet-mapping>
        <servlet-name>redirect</servlet-name>
        <url-pattern>/*jsessionid*</url-pattern>
    </servlet-mapping>

This is not forwarding the requests with jsession id and I have tested redirect.jsp which forwards correctly.

Update Following Balusc’s recommendation and another Filter I found here, I came up with this which does not seem to be working with regards to redirecting to my new site:

package org.thejarbar.web.filters;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import javax.servlet.*;
import javax.servlet.http.*;

public final class JSessionFilter implements Filter {

    public void init(FilterConfig filterConfigObj) {

    }

    public void doFilter(ServletRequest _req, ServletResponse _res,
                         FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) _req;
        HttpServletResponse res = (HttpServletResponse) _res;
        String url =req.getRequestURL().toString();

        if(Pattern.compile(Pattern.quote(url), Pattern.CASE_INSENSITIVE).matcher("jsessionid").find()){

            String redirectURL = "http://thejarbar.org";
            res.setStatus(301);
            res.setHeader("Location",redirectURL);
            res.setHeader( "Connection", "close" );
            res.sendRedirect(redirectURL);
        }

        chain.doFilter(req, res);
    }

    public void destroy() { }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:18:12+00:00Added an answer on June 6, 2026 at 9:18 am

    I finally got a Filter up that fixes my issue according to BalusC’s answer above and a post I found here

    My filter is implemented like this:

    package org.thejarbar.web.filters;
    
    import java.io.*;
    import java.util.regex.Pattern;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public final class JSessionFilter implements Filter {
    
        public void init(FilterConfig filterConfigObj) {
    
        }
    
        public void doFilter(ServletRequest _req, ServletResponse _res,
            FilterChain chain) throws IOException, ServletException {
            HttpServletRequest req = (HttpServletRequest) _req;
            HttpServletResponse res = (HttpServletResponse) _res;
            String url =req.getRequestURL().toString();
    
            if(url.indexOf(";jsessionid=")>0 || 
                url.indexOf("views/tutorials/linux/Maven-Setup.xhtml") > 0 ||
                url.indexOf("views/tutorials/windows/VirtualBox-Setup.xhtml") > 0 ||
                url.indexOf("views/tutorials/windows/Path-Setup.xhtml") > 0 ||
                url.indexOf("views/tutorials/windows/PATH-Setup.xhtml") > 0 ||
                url.indexOf("views/tutorials/linux/Netbeans-Install.xhtml") > 0) {
                String redirectURL = "http://thejarbar.org";
                res.setStatus(res.SC_MOVED_PERMANENTLY);
                res.setHeader("Location",redirectURL);
                res.setHeader( "Connection", "close" );
                return;
            }
    
            chain.doFilter(req, res);
        }
    
        public void destroy() { }
    }
    

    This links each of my outdated links to updated site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm participating in google code jam. Before anything I want to say that I
My application shows an alert that the user must respond to before continuing to
Just trying to understand that - I have never used it before. How is
I have used ImageView's before and understand the different scale types that can be
I've used MySQL (via PHPMyAdmin) a lot before but never really understood half of
Before Django 1.0 there was an easy way to get the admin url of
Before answering this question, understand that I am not asking how to create my
Google Chrome now, and Opera before, shows a spin box control beside a input
I'm working on a project that interfaces with Google Data APIs. I have several
I have been here before, asking for a mapping library that could store objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.