Lecture

Lecture - An Application Architecture The...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: An Application Architecture The Model-View-Controller (MVC) Architecture The MVC Architecture Provides separation between data, operations, and user interface The model represents: Data Manipulations of data The view handles: Display of data Interaction with user The controller: Maps user actions into data behaviour The MVC Architecture View Renders the data Requests updates from controller Sends user actions to controller Model Stores application state Exposes data operations Controller Defines application behaviour Maps user actions to data operations User Data Visualization User Action User Action Change View Data Queries Change Notification Data Change Deployment Files XML files describing your web applications Allow you to configure your servlets and JSPs: Pass them initialization parameters Allow them to recognize URL patterns e.g. *.cs would recognize: http://www.mysite.com/login/help.cs Allow you to create custom JSP tags for use in your JSPs (discussed later) Allow you to configure the security of your web application An Example Deployment File <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <servlet> <servlet-name>simple</servlet-name> <servlet-class>MySimpleServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>simple</servlet-name> <url-pattern>/SimpleServlet</url-pattern> </servlet-mapping> </web-app> Another Deployment Method Web applications can be grouped into Web Application aRchives (WAR files) Identical to JAR files, but the extension WAR is used for web applications, instead of applets The directory structure inside the WAR file should be identical to what you use for normal web applications: JSPs and static web pages: . Servlets: WEB-INF/classes Deployment Descriptor: WEB-INF/web.xml Demonstration Creating and Using a WAR File for Deploying a Web Application Servlets Continued Doing More With Servlets What Are Servlets? Similar to servers, but run inside a web server Or a web server extension called a Java engine Just like applets are similar to client programs, except they run inside a web browser Or a web browser extension called a Java virtual machine Since they run on the server, servlets typically do not have graphical user interfaces (GUIs) Demonstration The Hello World Servlet The Simplest Servlet public class MySimpleServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse response) { response.setContentType(text/html); PrintWriter out = response.getWriter(); out.println(<html><head>); out.println( <title>Servlets!</title>); out.println(</head><body>); out.println( <h1>Hello! World</h1>); out.println(</body></html>); } } Getting Parameters In the servlet: String name =...
View Full Document

Page1 / 43

Lecture - An Application Architecture The...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online