JSPs are much easier to work with in the presentation layer -- you can use
raw markup instead of enclosing all output in
response.getWriter.println("..."). Since you can include raw Java in JSPs as
well, you technically don't need servlets to build a full Java application.
That said, servlets are vital if you want to build an easy-to-maintain
application, reduce redundant code, and so forth.
In the Java Guestbook tutorial, the JSP is compiled and outputs an HTML form
-- the presentation. When the form is submitted, the form data is sent in a
request to /sign which is mapped to a servlet, SignGuestbookServlet, and
it's the servlet (not the JSP) which takes care of verifying authentication
and writing the data to the datastore. This is a fairly common pattern for
Java-based web applications and is not GAE-specific.

Here's more detailed info.:
http://java.sun.com/developer/technicalArticles/javaserverpages/servlets_jsp/

- Jason

On Sun, Oct 18, 2009 at 8:04 PM, Hung <[email protected]> wrote:

>
> So i've been a little confused about the different responsibilities of
> Servlets versus JSP.  I'm very new the GAE and got confused when
> looking at the guestbook tutorial.  It seems that
> GuestBookServlet.java has no responsibilities after guestbook.jsp was
> created.  However, the mapping of it in the xml says otherwise.  I
> know we should keep responsibilities between levels separate and it
> seems to me that the JSP should be responsible purely with the user
> interface and the servlets should be in charge of compiling all the
> data and deciding which datastore object i should be storing it to.
>
> If anyone could help clear this up for me that would be really
> helpful.
>
> Thanks
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to