PRJ321x_02 OUTCOME STANDARDS (12)
1. Understand how web applications work
a. A web application is a form of an application, based on the web interface
b. Using the 2 concepts of front-end (HTML, CSS, JS) and the back-end (JS, Java …), the
application is supposed to run to the developer’s liking
2. Understand, use HTML tags, handle simple events with javascript
a. HTML is comprised of tags, which determine how each element works. E.g a img (image)
tag, would be different to a p (paragraph) tag, as one displays an image, and the other
displays text
b. JS is designed to allow event handlers to happen, as well as more complex things, such as
transitions, carts, etc. to work within one website
c. Without HTML, CSS and JS, the web won’t function
3. Understand and program Servlets, JSP
a. Servlets are handlers for requests. They handle requests, responses, attributes etc. while
using Java
b. JSP is HTML, but by including java code, makes it easier to display dynamic content. JSP
contains “scriptlets”, which are embedded java code in the html. E.g: <%=1+1%>
c. Later on, JSTL + EL was developed, to phase out scriptlets.
4. Handles data submitted from html <form>
a. To handle data submitted via text, or other character-based content, JSP provides the
form tag
b. It may seem similar to HTML’s form tag, but JSP used 2 new attributes in it, action and
method
c. Action is what class, after pressing submit, will the form send to, in the form of
parameters
d. Method is what HTTP method is going to be used to transmit the data, most often GET
and POST
e. It is recommended to use POST for credentials, as GET displays the parameters in the URL
5. Handling data submitted from html <form> with JavaBean
a. After pressing the submit button, the FORM send data in the form of key:value pairs
b. The key and value must be a String or Number
c. To get the value, simple use request.getParameter(key)
6. Using MVC architecture in JSP/Servlet
a. MVC stands for Model, View and Controller
b. The Controller part is mainly the servlet/controller. The controller is designed to manage
requests from the view layer, and send it to the model layer, which then receives it from
the model layer, then send it to the view layer
c. The JSP falls into the view section, as it displays what is the visual part of the application
d. The Model is the logic behind the application, the things that determines what happens,
and where it happens. It can connect to the database, manipulating data to insert and
extract
7. Connect and manipulate the database using SQL through JDBC (need to put more details)
a. Download the MySQL connector for Java
b. Set the JAR to your build path using “Add External JAR”
c. Then, in your servlet/class, add a DriverManager class handling a Connection, with your
passwords for MySQL in it
d. There on, you can create a statement, and execute it
8. Proficient in using JSTL
a. JSTL is a library that tries to phase out scriptlets within JSP for newer, custom tags.
b. For example the c lib (core) has a new tag <c:forEach>. It is designed to replace having to
write a for loop in java.
c. JSTL wants for JSP to be free of Java.
d. Also with JSTL is EL, a built-in lib that compiles statements that follow this pattern ${…}
9. Manage state between requests in a session (state management) using session
object/cookie/hidden field/URL rewrite
a. URL rewriting is exactly what it says, rewriting the URL to add parameters to the URL, to
be parsed itself.
b. Servlet Context can also be used to manage the session, by adding hidden attributes,
viewed in the servlet context
c. To add a cookie to the session, simple create a cookie (Cookie cookie = new Cookie(“…”,
“…”)), and add it to the response object (response.addCookie(cookie)
d. You may also set the max age, before it expires.
10. Know how to install and set up the environment for the MVC framework, one of the most
popular frameworks today
a. Spring is a well-known MVC framework, out there with Struts
b. Go to commons.apache.org/logging and install the logging library there
c. Then go to https://repo.spring.io/release/org/springframework/spring, to import your
version of spring. Choose the one with dist in it
d. Then link it all into 1 eclipse project
e. Also, add to the build path Commons Logging, needed for spring
11. Build a simple Spring MVC controller application (need to be reviewed with mentor)
a. Create a java project
b. import all of the libraries above
c. create a Beans.xml. it can be named in any way, but often its Beans. use the file’s name
later
d. create a class called MainApp. Put this code in it:
----
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); //
where it says Beans.xml, put your xml file name in it.
HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
obj.getMessage();
----
e. then create another class called HelloWorld, with 1 attribute in it, message. Create a
getter and setter for that attribute
f. then, in the xml file, add this code:
----
<?xml version = "1.0" encoding = "UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id = "helloWorld" class = “class name here”>
<property name = "message" value = “message”/>
</bean>
</beans>
-----
g. Run the program
12. Know how to use Spring MVC framework to perform user authentication and account
registration on the website (need to be reviewed with mentor)
a. Simply use the same project as above, remove the old java files
b. Create a form that links to a controller. The form should have 2 text inputs, username +
password
c. Create the controller
d. In the JSP file, use EL with variables (remember the name later) to define what happens
e. In the controller, have a method that compares the username and password
f. In the web.xml, edit it to link to the controller (which the controller should have an
annontation of RequestMapping)
g. Edit the Beans.xml for a bean, to parse the jsp files
h. Run! (may cause problems)