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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:21:39+00:00 2026-06-11T20:21:39+00:00

I have developed a REST API using Play! Framework 1.2.4, and I have a

  • 0

I have developed a REST API using Play! Framework 1.2.4, and I have a strong liking for the framework. The simplicity and the rapid development cycle helped me achieve this in a fraction of the time I would have taken had I gone the traditional Java EE route.

Now that I am exploring using Play! 2.0.3 for my next project. I see that while the framework has been enhanced and makes it even easier to develop web-apps, the same cannot be said about REST API’s. My app will not have any HTML whatsoever – I will just respond with XML or JSON or whatever data exchange format I decide to use in future.

So, the question is:

Has anyone here used Play 2.0.x for exposing non-html pure REST API’s?

More Details:

Here are some of the factors I feel make it more difficult to develop pure REST API’s in Play 2.0.x compared to 1.2.x. Please correct my understanding if I am wrong.

Content Negotiation is harder

In play! 1.2.4, I content negotiation was build in to the framework. There were options to define right in the routes file what content-type a request expects.

GET /friends User.listFriends(format:'xml')

Then, in the controller,

public static void getFriends(){
    render();
}

This would result in the views/xml/User/listFriends.xml template being rendered automatically. To add support for JSON tomorrow, all I needed to do was to add a views/json/User/listFriends.json template.

I do not see how this can be done in play! 2.0.x

Creating non-html templates is less intuitive

After some trial and error, I figured out that one can create, for example, a listFriends.scala.xml in the views folder in play! 2.0. Then, it needs to be invoked in the controller code as follows:

return ok(views.xml.listFriends.render());

However, Eclipse doesn’t like this, because Eclipse does not know about the views.xml.listFriends since it is generated only after play compilation completes. Is there anything I’m missing here?

  • 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-11T20:21:40+00:00Added an answer on June 11, 2026 at 8:21 pm

    In Play (Scala) you can do something like this:

    val myXMl = obtainXML();
    return Ok(myXML).as("text/xml")
    

    I’m not sure of the syntax in Java, but it would be equivalent: instead of creating a template, you generate the XML and then you send it to the user, setting the return type to “text/xml” (or json or whatever you need it to be).

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

Sidebar

Related Questions

I have a REST api with Gzip compression enabled, it's developed using the ASP.net
I have a REST api developed with django-tastypie . I have a couple of
I'm developing a Facebook application using their Graph API. I have previously developed an
I noticed that using LinkedIn REST API in my application, i have a strange
I have developed a REST application server based on RESTEasy (JAX-RS). I have a
I have developed sample api as jar file. This jar file contains the code
I have developed a website using Razor (Microsoft WebMatrix) and now I want to
I have developed a Java server using Eclipse that accepts TCP socket connection from
I'm using the old Rest API (and old Javascript SDK) to develop an iframe
I have a website developed using ASP.NET MVC3. I now want to expose a

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.