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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:56:43+00:00 2026-05-27T20:56:43+00:00

Does servlet support urls as follows: /xyz/{value}/test where value could be replaced by text

  • 0

Does servlet support urls as follows:

/xyz/{value}/test

where value could be replaced by text or number.

How to map that in the web.xml?

  • 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-05-27T20:56:44+00:00Added an answer on May 27, 2026 at 8:56 pm

    Your best bet is the URL pattern /xyz/*.

    The Servlet API doesn’t support to have the URL pattern wildcard * in the middle of the mapping such as /xyz/*/test nor URI templates. It only allows the wildcard * in the end of the mapping like so /prefix/* or in the start of the mapping like so *.suffix.

    You can extract the path information using HttpServletRequest#getPathInfo(). Here’s a basic kickoff example how to extract the path information, null and array index out of bounds checks omitted for brevity:

    @WebServlet("/xyz/*")
    public class XyzServlet extends HttpServlet {
    
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            String pathInfo = request.getPathInfo(); // /{value}/test
            String[] pathParts = pathInfo.split("/");
            String value = pathParts[1]; // {value}
            String action = pathParts[2]; // test
            
            if ("test".equals(action)) {
                // ...
            }
        }
    }
    

    If you want to be able to use URI templates nonetheless, and this is actually intended to be a REST endpoint rather than a HTML page, then take a look at Jakarta REST (JAX-RS):

    @Path("/xyz/{value}/test")
    public class XyzResource {
    
        @GET
        @Produces(MediaType.APPLICATION_JSON)
        public String getTest(@PathParam("value") String value) {
            // ...
        }
    }
    

    If you want more finer grained control liks as possible with Apache HTTPD’s mod_rewrite, then you could look at Tuckey’s URL rewrite filter or homegrow your own URL rewrite filter.

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

Sidebar

Related Questions

What Servlet Spec and JSP version does Jboss 4.2.3 support?
C:\Tomcat5.5\webapps\WEB-INF\classes>javac MyServlet.java MyServlet.java:2: package javax.servlet does not exist import javax.servlet.*; ^ MyServlet.java:3: package javax.servlet.http
Does the FacesServlet in JSF 2.0 support the servlet 3.0 async features?
I have a servlet Filter that acts as the basis of my web stack.
I added Comet servlet into Spring web application. This servlet does not differ from
Does the Java language have delegate features, similar to how C# has support for
Does anyone have any recommendations of tools that can be of assistance with moving
Does anyone use have a good regex library that they like to use? Most
Does anyone know how to transform a enum value to a human readable value?
I'm developing a web app that needs to do some backend processing while still

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.