Continuing from our first scenario where we presented a Welcome to the user Terrance Streeter, this example demonstrates how we allow the same user to look at their own Profile page where they can view their personal data and update it as necessary. For the sake of simplicity, we will obtain only the users first and last name, their email address and password. These are typically what you allow the user to make changes on for a Profile page. We will not perform any field validation for this example as that would detract from the lesson.
Under the Java tab, you can see how we branch off the business logic by testing for the value of the "action" parameter. For a more sophisticated setup, your web application could allow for other actions such as "delete" if the user didn't want to be a member on your website any longer. Note how we take advantage of the GSON class, which is a dependency for JED, to create a JSON string and return it to the client side.
For our controller JSP, also note that we are introducing three additional objects: the Query class, the Field class, and the WhereCondition class. The Query class is responsible for assembling the correct syntax for SQL statements: SELECT,INSERT,UPDATE,DELETE. If we want to perform an UPDATE, we will need to involve instances of all these classes along with the Database class. The comments in the JSP will explain how they all come together.