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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:36:16+00:00 2026-05-23T14:36:16+00:00

I have a simple RESTful web service that print Hello World ! I’m using

  • 0

I have a simple RESTful web service that print “Hello World !”
I’m using NetBeans and the code looks like:

package resource;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;


@Path("simple")
public class SimpleResource {

    @Context
    private UriInfo context;

    /** Creates a new instance of SimpleResource */
    public SimpleResource() {
    }

    @GET
    @Produces("application/xml")
    public String getXml() {
        //TODO return proper representation object
        return "<greeting>Hello World !</greeting>";
    }

    @PUT
    @Consumes("application/xml")
    public void putXml(String content) {
    }
}

I call this web service from this URL : http://localhost:8080/WebService/resources/simple.
Now, I want to send a parameter to this web service, then print this parameter after the “Hello world” message.

How can we do that?

Thanks!

  • 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-23T14:36:17+00:00Added an answer on May 23, 2026 at 2:36 pm

    The two main ways of handling a parameter in REST are via parsing the path and via extracting the query part.

    Path parameters

    These handle this case — /foo/{fooID} — where {fooID} is a template that will be replaced by the parameter you want:

    @GET
    @Produces("text/plain")
    @Path("/foo/{fooID}")
    public String getFoo(@PathParam("fooID") String id) {
        // ...
    }
    

    These are great for the case where you can consider the parameter to be describing a resource.

    Query parameters

    These handle this case — /?foo=ID — just like you’d get from doing traditional form processing:

    @GET
    @Produces("text/plain")
    @Path("/")
    public String getFoo(@QueryParam("foo") String id) {
        // ...
    }
    

    These are great for the case where you consider the parameter to be describing an adjunct to the resource, and not the resource itself. The @FormParam annotation is extremely similar, except it is for handling a POSTed form instead of GET-style parameters

    Other types of parameters

    There are other types of parameter handling supported by the JAX-RS spec (matrix parameters, header parameters, cookie parameters) which all work in about the same way to the programmer, but are rarer or more specialized in use. A reasonable place to start exploring the details is the JAX-RS javadoc itself, as that has useful links.

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

Sidebar

Related Questions

I'm using ASP.NET MVC controllers for providing RESTful web services. That works just fine
We currently have a SOAP based web service that our in house applications use
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
I have a simple webform that will allow unauthenticated users to input their information,
I have a simple 2-column layout with a footer that clears both the right
I'm out to create a fairly simple web service for intranet use. The service
I'm building a web service with a RESTful interface (lets call it MY_API ).
I'm building a web service with a RESTful interface (lets call it MY_API ).
I have simple regex \.*\ for me its says select everything between and ,

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.