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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:11:13+00:00 2026-06-03T11:11:13+00:00

Just doing a little comparison with spring and jersey. Curious if it is possible

  • 0

Just doing a little comparison with spring and jersey.

Curious if it is possible for a method to return both xml or json.

Maybe default to xml, but have an optional flag that will return json.

Possible?

  • 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-03T11:11:14+00:00Added an answer on June 3, 2026 at 11:11 am

    You mention Jersey, so I assume you are referring to a REST implementation. Jersey will automatically serialize your content as XML and JSON if your resource is properly setup. You just have to indicate a wider range of media types for your @Produces annotations:

    @GET
    @Path("/somepath")
    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
    public MyBean getData() ;
    

    Where MyBean is an appropriately JAXB annotated POJO. With this resource endpoint definition a caller can specify what content type they want via the Accept: header:

    GET http://www.example.com/somepath
    Accept: text/xml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a JavaScript newbie, just doing a little script so that I can rotate
Doesn't seem to work for me, maybe I just doing it wrong
Hi am just doing a little animation which moves an object from point a
Just doing a little touch up before finishing a conversion project and I have
Just doing a little introduction to JavaScript. I'm used to more than often testing
I've been doing some little code quizes just to catch back up on my
I'm coming from the C# world and has just started doing a little PHP
Just doing a bit of reading up on Generics. I have written a little
I am just doing a little work this morning making some static libraries. Why
Just doing a small project relating to google maps. Basically I have coordinates in

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.