Tutorialspoint examples

Learn java tutorial with examples for beginners online

Jax-rs path multiple parameters example

RESTful web services:

REST stands for REpresentational State Transfer. Unlike SOAP it is a web standards based architecture and not protocol. It uses HTTP protocol for data communication. REST provides the facility to represent a resource in various formats like text, JSON and XML.

Note: JSON is the most popular format.

Jax-rs path multiple parameters jersey example


package com.javawithease.ws;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType; 
public class TestWS {	
 public Response getMassegeWithSingleParam(
		                @PathParam("id") String id) {		 
	String output = "RESTful WS Jersey example. " +
			"Hello your id is : " + id; 
	return Response.status(200).entity(output).build(); 
 public Response getMassegeWithMultiParam(
	@PathParam("name") String name,
	@PathParam("class") String className, 
	@PathParam("rollNo") String rollNo) {		 
	String output = "Student Name : " + name + ", Class: " 
			+className+ ", Roll No. : " + rollNo; 
	return Response.status(200).entity(output).build(); 


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
  	<display-name>JAX-RS REST Servlet</display-name>
  	<servlet-name>JAX-RS REST Servlet</servlet-name>
  	<servlet-name>JAX-RS REST Servlet</servlet-name>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>WS Test</title>
   <a href="services/helloTest/04">Single Parameter Test.
   <a href="services/helloTest/jai/MCA/04">Multiple Parameter Test.


jax-rs example3.1
Click on “Single Parameter Test” link.
jax-rs example3.2
Click on “Multiple Parameter Test” link.
jax-rs example3.3
Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status