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 119187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:36:48+00:00 2026-05-11T03:36:48+00:00

I’m trying to add URL routing to a web application running in Tomcat 5.5.

  • 0

I’m trying to add URL routing to a web application running in Tomcat 5.5.

I want to make the dynamic page URLs more friendly, changing main.jsp?type=test&group=info to main/test/info as is all the rage.

I have set up the following in the web.xml

  <servlet>     <servlet-name>main</servlet-name>     <jsp-file>/main.jsp</jsp-file>   </servlet>   <servlet-mapping>     <servlet-name>main</servlet-name>     <url-pattern>/main/*</url-pattern>   </servlet-mapping> 

and in main.jsp I use request.getPathInfo() to get the data that I need to do the routing. All this seems to work fine, and when I browse to http://mytestserver/example/main/test/info I get the html that I expect.

The problem is that any relative links on that page, images, style-sheets, javascript, etc., are now all broken, as they are being interpreted as relative to the full URL.

I can’t think of an easy way to use static links because the URLs on the test server and production server are at different levels: http://mytestserver/example/ maps to http://example.com/ in production, and I really do not want to have to write code to wrap every internal link on the site or set up a virtual server for each site on the test server.

Is there anything else I can do?

  • 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. 2026-05-11T03:36:49+00:00Added an answer on May 11, 2026 at 3:36 am

    I have a system like this at work.

    We use a package called urlrewrite, which basically is the apache tomcat rewriter done up as a j2ee filter. It’s cool, but I ran into this same problem.

    To fix it, I wrote another filter which is inserted into the filter chain before the rewriter. Its job is to grab the pathinfo before the rewriter mangles it, and to stick that info into a request attribute. It resolves the pathinfo of the request against the pathinfo of the web application root, to work out how many "../" you need to get to the root of the web app (from the client’s point of view).

    The other components of the system then use the content of that attribute to build their relative urls. Works great.

    The system is here.

    Look for any taxon (MACROPODIDAE is a fine choice). All the rest-y looking links get turned into reqest parameters by the url remapper.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.