views:

85

answers:

2

I have this :

public class Base {

    @GET
    @Path("/news/{page_number}")
    public Viewable news(@PathParam("page_number") int pageNumber) {

        NewsParams news_params = new NewsParams();
        news_params.setPageNumber(pageNumber);

        return new Viewable("/news.jsp", news_params);
    }
}

and the news.jsp is :

   ${it.pageNumber}

My question is : What to do (or which is the best way) if a have a lot of objects to transfer from jersey restful classes (which represent the application logic) to the JSP pages (which represent the application view) ?

A: 

You could pass a POJO to the Viewable instead. If you were to pass a Customer object with an Address property then you could access the date in your JSP as follows:

${it.firstName}
${it.lastName}
${it.address.street}
${it.address.city}
Blaise Doughan
A: 

The way to go is to pass a POJO to the Viewable and use as shown by Doughan above. In addition to that you could also pass around request attributes or via session, though personally I always try to avoid session wherever and whenever possible.

Example of passing request attributes can be found at - http://goo.gl/5NsW Line 56, 57 and 103 will comprise of the example.

imyousuf