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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:02:36+00:00 2026-05-30T03:02:36+00:00

This is my method for creating Response with header parameters and body: public Response

  • 0

This is my method for creating Response with header parameters and body:

public Response sendOKResponse(request req)
{
    ResponseBuilderImpl builder = new ResponseBuilderImpl();
    // set the header params.
    for(int index =0; index<req.headerParameters.size(); index++)
    {
        builder.header(req.headerParameters.get(index).getName(), req.headerParameters.get(index).getBody());
    }

    // set the body and response code
    builder.status(Response.Status.OK).entity(req.getBody());
    Response r = builder.build();
    return r;
}

And this is how i return the Response:

Response response;
response = sendBadMesseage();
        return response;

This code returns code 204(No content) instead of 200.
Any ideas why?

  • 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-30T03:02:37+00:00Added an answer on May 30, 2026 at 3:02 am

    You shouldn’t be instantiating your response builder with new, the whole point of the JAX-RS abstraction layer is to hide implementation details away from calling clients. This is what makes it possible to have various vendor implementations which can be interchanged at will. Also, if you are using JEE6, or hope to migrate to it, this code will almost certainly fail. Most JEE6 vendor implementations utilize CDI, which is concept-incompatible with usage of new. But, closer to the topic, the JAX-RS implementation specifies that a 204 status code be returned if a responses wrapped entity is null. You might want to verify this is not the case in any of your methods. Also, you might want to make some changes to your code:

    public Response sendOKResponse(request req) {
        ResponseBuilder response = Response.ok();
    
        // set the header params.
        for(Header h: req.headerParameters()) {
            builder = builder.header(h.getName(), h.getValue());
        }
    
        // set the body and response code
        builder = builder.entity(req.getBody());
    
        return builder.build();
    }
    

    Your sendBadMessage method should also look similar to above. You can log your entity before adding it to the builder, to verify that you only get a 204 when it’s null.

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

Sidebar

Related Questions

I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
I am creating a MKMapView in a method named generateMap. From inside viewDidLoad, this
Can this method work? public String sayHello(){ return Hello.jsp?name= + laala; } I am
This is what I am currently using for registration: def register(request): if request.method ==
I am having some trouble creating a request to this WSDL that works; it
I am new to AJAX and have this issue. I am creating a photogallery
I'm not really familiar with creating generic methods, so I thought I'd put this
This method works as expected - it creates a JTree with a root node
With this method declaration (no overloads): void Method(double d) { // do something with
Take this method /** * @return List of group IDs the person belongs to

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.