Java Web Technologies
Java Web Technologies
Week 09
Java Web Technologies
Learning Outcomes
2
SLIIT - Faculty of Computing
Object Oriented Programming
MVC
MVC Cont..
• The model does all the computational work
– It is input/output free
– All communication with the model is via
methods
• The controller tells the model what to do
– User input goes to the controller
• The view shows results; it is a “window” into
the model
– The view can get results from the controller, or
– The view can get results directly from the model
SLIIT - Faculty of Computing
Object Oriented Programming
• Controller:
– Java servlet; session Bean
• Model:
– Entity Bean or other business logic object
SLIIT - Faculty of Computing
Object Oriented Programming
Interchangeable Elements
• View:
– HTML form becomes touch-screen
• Controller:
– JSP becomes session bean
• Model:
– Entity Bean
• Views and Controllers closely interact (HTML/JSP)
• If HTML code is written out entirely through JSP, the Controller and
View (conceptually) merge
• A Controller-View pair works with one Model
• One Model may have multiple Controller-View pairs
MVC Advantages
JSP Example
• High Performance
• Has access to all the powerful Enterprise
Java APIs, including JDBC, JNDI, EJB, JAXP
• can be used in combination with servlets
Scripting Elements
Declarations
Scriptlets
• Used to embed java code in JSP pages.
• Contents of JSP go into _JSPpageservice()
method
• Code should comply with syntactical and
semantic constuct of java
• Embedded in <% and %> delimiters
– Example:
<%
int x = 5;
int y = 7;
int z = x + y;
%>
Expressions
JSP Actions
JSP Actions
Syntax
• Scriplet – nest Java code
What is a Servlet?
• Servlets are small programs that execute on the server
side of a web connection
• Servlets dynamically extend the functionality of a web
server
• Java Servlets/JSP are part of the Sun’s J2EE Enterprise
Architecture
– The web development part
• Java Servlet
– is a simple, consistent mechanism for extending the
functionality of a web server
– Are precompiled Java programs that are executed on
the server side.
– Require a Servlet container to run in
– Portable to any java application server
– Response Body
Maven Architecture
Plugin
e.g. jar
Projects Plugin
Maven Core
to build e.g. surefire
Plugin
e.g. release