Why GXP (as opposed to Servlets/JSP)?

18 views
Skip to first unread message

joshuatbrown

unread,
Jul 24, 2008, 9:26:37 AM7/24/08
to gxp-users
Could you explain what GXP provides that Servlets/JSP doesn't? To me,
it looks very similar to what JSP provides (with JSTL). What are some
of the differences? When would be a good reason to use it as opposed
to Servlets/JSP?

Laurence Gonsalves

unread,
Jul 24, 2008, 3:18:06 PM7/24/08
to gxp-users
That's a great question!

Check out this page for a comparison between GXP and other templating
systems, particularly JSP:
http://code.google.com/p/gxp/wiki/WhyGxp

By the way, GXP is not an alternative to Servlets, but instead
complements them. A typical web application might have its business
logic implemented in Servlets and then use GXPs for the presentation
layer.

We'll try and write some more documentation showing how one invokes a
GXP from a Servlet, but the basic idea is that you get the Writer from
your ServletResponse (using getWriter()), and then pass this to a
GXP's write() method as the first parameter. This might look something
like this:

/**
* A servlet for viewing the "stuff".
*/
public class ViewStuff extends HttpServlet {
...
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {

// business logic goes here

// "StuffPage.gxp" has the presentation logic
StuffPage.write(
response.getWriter(),
new GxpContext(request.getLocale()),
/* parameters computed by business logic go here */);
}
}
Reply all
Reply to author
Forward
0 new messages