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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:09:24+00:00 2026-06-09T23:09:24+00:00

I am building a webservices application using jersey,jax-rs I have single jax-rs resource file

  • 0

I am building a webservices application using jersey,jax-rs

I have single jax-rs resource file at path “/authenticate”

I have multiple methods with individual paths like “/user” “/test”

@Path ("/authenticate")
public class Authenticate{
private static final Log log = LogFactory.getLog(Authenticate.class);

@QueryParam("entityId")
String entity;

@GET
@Path ("/{param}")
public Response getMsg(@PathParam ("param") String msg) {
    String o = "Hello Welcome Back:"+msg;
    return Response.status(200).entity(o).build();
}

@GET
@Path ("/user")
@Produces({"application/json"})
public UserDTO getUser (@Context HttpServletRequest request,
        @QueryParam("userId") int userId) {
    System.out.println("In Get User, User:"+userId);    
    System.out.println("In Get User, Entity:"+entity);
}

@GET
@Path ("/test")
@Produces({"application/json"})
public TestPOJO getTestPOJO () {
    System.out.println("In Get TestPOJO");
    System.out.println("In Get Test, Entity:"+entity);
    return new TestPOJO();
}

}

As suggested for jersey client, I am using a single webresource from client and build subsequent webresources from the same webresource by using .path(“/xxx”).

Here is how I create the initial web resource

WebResource webResource = client.resource("http://localhost:8080/Service/jaxrs/authenticate");
webResource.queryParam("entityId", securityHelper.getEntityId().toString());

Here is how I use the webresource subsequently

MultivaluedMap<String, String> params = new MultivaluedMapImpl();           
ClientResponse userRes = webResource.path("/user").queryParams(params).accept("application/json").get(ClientResponse.class);

I want to assign a queryparam to the initial webresource, and I want that to be retained by all subsequent webresources created using the .path(). But that is not happening right now. For example in the above code “entityId” is not available when the call with path(“/user”) is made.

My idea is to assign common parameters once and all subsequent users of the webResource need not add those again and again. Is there a way to do it? Will this approach work?

  • 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-06-09T23:09:25+00:00Added an answer on June 9, 2026 at 11:09 pm

    The line below creates a new WebResource and not changing the state of the webResource object:

    webResource.queryParam("entityId", securityHelper.getEntityId().toString())
    

    Eventually you could change your code like this to create the “base” resource:

    WebResource webResource = client.resource("http://localhost:8080/Service/jaxrs/authenticate").queryParam("entityId", securityHelper.getEntityId().toString());
    

    And then use this resource to create another resources as you like. WebResource.queryParam and WebResource.queryParams always create a new WebResource object.

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

Sidebar

Related Questions

I have a number of different webservices in the C# web application I'm building
I'm building an application using OpenJPA 2.0.0, Jersey 1.3, and JUnit 4.8.1. I've set
I am using Jersey Framework (JAX-RS implementation) for building RESTful Web Services. I'm not
I'm building an Intranet application based on Ext JS and webservices. Users are authorized
I am building a standard asp.net LOB application. i am planning to have some
I am building a distributed application using Distributed OSGi and Zookeeper. The application should
I am building a web application with RESTful web services using Spring MVC 3.
I have a web application that exposes web services using WCF and wsHttpBindings. It
I'm building a MVC web application (using the Spring MVC framework), and I'm a
I am looking at building a client server application in C# using winforms or

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.