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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:57:57+00:00 2026-05-23T02:57:57+00:00

I am using Jersey JAX-RS. I want to return a Response with a Map

  • 0

I am using Jersey JAX-RS.
I want to return a Response with a Map containing Image Files and JSON String values.

Is this the right way to do this:

Map<String,Object> map = new HashMap........


GenericEntity entity = new GenericEntity<Map<String,Object>>(map) {};

return Response.ok(entity).build();

Or is this better.I plan to use JAX-RS with Jersey only.

JResponse.ok(map).build();

I am basing this on this article:

http://aruld.info/handling-generified-collections-in-jersey-jax-rs/

I am not sure what to specify for @Produces too(planning to leave it out).

TIA,

Vijay

  • 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-23T02:57:57+00:00Added an answer on May 23, 2026 at 2:57 am

    You better produce a multipart response:

    import static com.sun.jersey.multipart.MultiPartMediaTypes.MULTIPART_MIXED_TYPE;
    import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE
    
    @GET 
    @Produces(MULTIPART_MIXED_TYPE) 
    public Response get() 
    { 
      FileDataSource image = ... (gets the image file) 
      String info = ... (gets the xml structured information) 
    
      MultiPart multiPart = new MultiPart(). 
      bodyPart(new BodyPart(info, APPLICATION_XML_TYPE)). 
      bodyPart(new BodyPart(image, new MediaType("image", "png"))); 
    
      return Response.ok(multiPart, MULTIPART_MIXED_TYPE).build(); 
    }
    

    This example was taken from there.

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

Sidebar

Related Questions

I want make RESTful services using embedded jetty with JAX-RS (either resteasy or jersey).
I'm using Jersey (jax-rs), to build a REST rich application. Everything is great, but
I am querying a database for a web service using the Jersey JAX-RS. I
Using Jersey 1.7, JAX-WS 2.2.3, Tomcat 6.0.30 and the following method declaration prevents Jersey
I'm using Google Guice with Jersey (jax-rs). Following method throws an JAXB-Exception (JAXB can't
I am using the JAXB that is part of the Jersey JAX-RS. When I
How do I set the xml namespace when using Jersey, jaxb & jax-rs
I have a JAX-RS REST service implemented using Jersey. One of the cool features
Using Jersey/JAX-RS I have a get handler that contains code to copy a large
I have a JAX-RS web service (using jersey) that accepts a JAXB object as

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.