HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Jersey / Jersey – Case-insensitive @Path URLs

Jersey – Case-insensitive @Path URLs

By default in JAX-RS, ALL URLs specified in @Path annotations are CASE-SENSITIVE. In this tutorial, I am giving a simple example of CASE-INSENSITIVE URLs which cane be used inside @Path annotation on any Jersey JAX-RS REST API.

How to make URLs case in-sensitive

To make URLs case-insensitive, change the @Path URLs like below:

@Path("/{employees}")
public class JerseyService 
{
	//Code
}

Change above declaration to this:

@Path("/{employees : (?i)employees}")
public class JerseyService 
{
	//Code
}

Now above @Path annotation will be able to match any variation of lowercase and UPPERCASE letters in employees.

Please note that for this example, I am using Jersey 2.19.

Demo Usage

Here, I am modified the sourcecode of my previous example of Jersey RESTful Client Examples.

I sent following requests to HTTP GET /{employees : (?i)employees} path, and all paths matches correctly.

http://localhost:8080/JerseyDemos/rest/EMPLOYEES

Case-insensitive URL - 1
Case-insensitive URL – 1

http://localhost:8080/JerseyDemos/rest/EmPlOyEEs

Case-insensitive URL - 2
Case-insensitive URL – 2

http://localhost:8080/JerseyDemos/rest/employees

Case-insensitive URL - 3
Case-insensitive URL – 3

Feel free to contact in you find any problem in this example.

Happy Learning !!

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Reddit

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. Suryavas

    December 31, 2016

    Very informative

Comments are closed on this article!

Search Tutorials

Jersey Tutorial

  • Jersey – Hello World
  • Jersey2 – Hello World
  • Jersey – quickstart-archetype
  • Jersey – Custom Logging
  • Jersey – Set Cookie
  • Jersey – File Download
  • Jersey – File Upload
  • Jersey – Multi-File Upload
  • Jersey – Exception Handling
  • Jersey – MOXy JSON
  • Jersey – JSONP
  • Jersey – Google Gson
  • Jersey – Security

Jersey Client

  • Jersey Client – Access REST APIs
  • Jersey Client – Authentication
  • Jersey Client – Set Cookie

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Java 15 New Features
  • Sealed Classes and Interfaces
  • EdDSA (Ed25519 / Ed448)