JAX-RS @MatrixParam Restful Webservice

In this tutorial we are going to see JAX-RS MatrixParam using RESTful web service @MatrixParam annotation. MatrixParam is set of name value pair separated by semi colon, for example name = value;

Ask your questions in Our Forum

To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Create maven web application project and add Jersey dependency in pom.xml. Find Jersey 2.x maven dependency configuration below. If you are new to maven refer our maven tutorials.

Jersey 2.x dependency in pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <name>RestTutorials Maven Webapp</name>
      <!-- JAX-RS -->
        <!-- Jersey 2.19 -->


package com.ehowtonow.webservice;

import javax.ws.rs.GET;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

public class MatrixParamService {

	public Response getTutorial(@PathParam("site") String site,
			@MatrixParam("tutorial") String tutorial,
			@MatrixParam("rank") String rank) {
		return Response
				.entity("Web Site : " + site + "  Tutorial : " + tutorial
						+ " Rank : " + rank).build();



Configure Jersey 2.x Servlet dispatcher

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

	<display-name>Restful Webservice Example</display-name>


Now you can run the service and access the service by calling the following URL


Ask your questions in Our Forum

To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

Posts You may Like

  1. How to get File Last modified Date in Java
  2. Remove the particular character from string
  3. Java Best Practice Reuse Objects instead of creating new ones if possible
  4. How to check hidden file or directory using Java
  5. Java Tutorial – Java Introduction
  6. Download Text file using JAX-RS RESTful Webservice
  7. Java Best Practice – File Organization
  8. How to make collection read-only
  9. How to delete directory using Java
  10. Java 8 Sort Map by Value
  11. Java Best Practice Programming Practices
  12. First Java Application in Eclipse
  13. Java 7 Try statement with resources
  14. Java Best Practice – White Spaces
  15. How to rename the file using Java

Be the first to comment

Leave a Reply

Your email address will not be published.