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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:01:36+00:00 2026-06-01T04:01:36+00:00

I have Apache Tomcat Version 7.0.26 running. A have a JAX-RS servlet under /test,

  • 0

I have Apache Tomcat Version 7.0.26 running.

A have a JAX-RS servlet under /test, which calls jsps which in tourn should be handled by the Tomcat servlet engine.

E.g.,
/test should be handled by jersey, but /test/result.jsp should be handled by the JSP engine.

I don’t want the user to see different urls, therefore, I rewrite the jsp URLs to /jsp internally.

Config is like that:

UrlRewriteFilter (in urlrewrite.xml):

<rule>
    <from>^/([^j][^s][^p].*\.jsp)</from>
    <to>/jsp/$1</to>
</rule>

web.xml:

<filter>
   <filter-name>UrlRewriteFilter</filter-name>
   <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
   <!-- set the amount of seconds the conf file will be checked for reload
   can be a valid integer (0 denotes check every time,
      empty/not set denotes no reload check) -->
   <init-param>
     <param-name>confReloadCheckInterval</param-name>
     <param-value>0</param-value>
   </init-param>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<servlet>
  <servlet-name>Test</servlet-name>
  <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>test</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Test</servlet-name>
  <url-pattern>/test/*</url-pattern>
</servlet-mapping>

A call to /xyz.jsp is redirected to /jsp/xyz.jsp. A call to /test/xyz.jsp leads to 404 - Servlet Test is not available. I thought that filters have precedence over servlets, don’t they?

I am aware of the related question Servlet vs Filter, but they don’t state anything about the precedence.

BTW: PrettyFaces seems to be similar to UrlRewriteFilter, but I haven’t tried it yet. I (currently) like UrlRewriteFilter more.

EDIT: The question How to mix server-side Jax-rs call with native files without prefix? asks the question behind my question.

  • 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-01T04:01:38+00:00Added an answer on June 1, 2026 at 4:01 am

    Actually you can make it work quite easily and you don’t need any url rewriting. Just place your jsp’s into test/ dir, register Jersey as a servlet filter instead of a servlet (i.e. replace all occurrences of servlet with filter in your web.xml) and add com.sun.jersey.config.feature.FilterForwardOn404 init param set to true. The resulting web.xml should look as follows:

    <filter>
      <filter-name>Test</filter-name>
      <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
      <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>test</param-value>
      </init-param>
      <init-param>
        <param-name>com.sun.jersey.config.feature.FilterForwardOn404</param-name>
        <param-value>true</param-value>
      </init-param>
    </filter>
    <filter-mapping>
      <filter-name>Test</filter-name>
      <url-pattern>/test/*</url-pattern>
    </filter-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have apache 2.2 and tomcat 5.5 running on a Windows XP machine. Which
I have a J2EE-based system which is running currently on Apache Tomcat. We are
I have an instance of Apache Tomcat 6.x running, and I want it to
I have a simple servlet running in Tomcat. Because the servlet connects to a
I have a web application that's currently running under Tomcat 5.5.25. I'm attempting to
I have an application that usually is hosted on a Windows 2003 Apache Tomcat
I have Apache running on a public-facing Debian server, and am a bit worried
I have Apache 2 running on a VPS server (running Debian). I recently changed
I have Apache/SVN running on Windows Server 2003 with authentication via LDAP/Active Directory and
We have an Apache tomcat server that runs a current web service. We were

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.