2 Agenda Stefanie Selzer - Pascal Busch - Michael Kropiwoda I Einleitung + Dynamische Seiten +...

Post on 05-Apr-2015

107 views 1 download

Transcript of 2 Agenda Stefanie Selzer - Pascal Busch - Michael Kropiwoda I Einleitung + Dynamische Seiten +...

2

Agenda

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen + MVC II Struts + Framework + Komponenten + Controller + Model + View + Zusammenspiel der KomponentenIII Fazit + Vorteile/Nachteile + Alternativen

3

Dynamische Seiten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Browser

Browser

DynamischeSeite

request

response

Web Server

Data Sources

Applikation

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

StatischeSeite

request

response

4

Servlet

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

ClientClient Servlet

request

response

Web Server

Data Sources

Enterprise Server

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

serverseitige Java-Komponente

verschiedene Ausgabeformate möglich

5

JSP Model I

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Browser

Browser

JSP Seite

JavaBean

request

response

Web Server

Data Sources

Enterprise Server

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

6

JSP Model II

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Browser

Browser

JSP Seite JavaBean

request

response

Web Server

Data Sources

Enterprise Server

Controller

instantiiert

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

7

MVC

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

View

User Model

Controller

8

Framework

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Vorgefertigte Anwendungskomponenten

Vorgegebene Architektur

Plattformunabhängigkeit

Ziele:

Schnellere Entwicklungszeiten

Bessere Abbildung der Prozesse

9

Struts – Komponenten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Web ServerController

• Action Servlet

• Action Mapping/Action Forward

• struts-config.xml

• Action

View

• JSP Seite

• Taglibs

• Properties

Model

• Java Beans

• ActionForm

10

Controller – Komponenten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

die Klasse ActionServlet

die Datei struts-config.xml

die Klasse ActionMapping

die Action-Klassen

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

11

Controller – ActionServlet

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

erbt von ActionServlet

übernimmt Ablaufsteuerung Mapping

Erzeugung weiterer Komponenten

Action-Objekte (Ausführung spezifischer Aufgaben)

ActionForm-Objekte (Speichern und validieren von Daten aus HTML-Formularen)

ActionForward-Objekte (Weiterleitung des Programflusses)

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

12

Controller – struts-config.xml

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Controller

request

Struts-config

„Controller“ActionServlet

13

Controller – struts-config.xml

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Definition und Konfiguration von:

Datenquellen

Form-Bean Definitionen<form-beans> .... </form-beans>

Globale Forward-Definitionen<global-forwards>...</global-fowards>

Action-Mapping <action-mappings> ... </action-mappings>

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

14

Controller – struts-config.xml

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

<struts-config>

<form-beans> <form-bean name="logonForm“ type="org.apache.struts.example.LogonForm"/> </form-beans>

<global-forwards type="org.apache.struts.action.ActionForward"/> <forward name="logon“ path="/logon.jsp" redirect="false"/></global-forwards>

<action-mappings> <action path="/logon“

type="org.apache.struts.example.LogonAction“name="logonForm" /><forward name= “failure“ path="/logon.jsp„ /><forward name= “success“ path="/main.jsp" />

</action></action-mappings>

</struts-config>

<struts-config>

<form-beans> <form-bean name="logonForm“ type="org.apache.struts.example.LogonForm"/> </form-beans>

<global-forwards type="org.apache.struts.action.ActionForward"/> <forward name="logon“ path="/logon.jsp" redirect="false"/></global-forwards>

<action-mappings> <action path="/logon“

type="org.apache.struts.example.LogonAction“name="logonForm" /><forward name= “failure“ path="/logon.jsp„ /><forward name= “success“ path="/main.jsp" />

</action></action-mappings>

</struts-config>

15

Controller – ActionMapping

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Controller

request

ActionMapping

Struts-config

„Controller“ActionServlet

16

Controller – ActionMapping

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

erbt von ActionMapping

bildet das jeweilige Ereignis auf die zuständige

Action-Klasse ab

Attribute:

path - Request-URI-Pfad

type - Klassenname der Klasse, welche diese Action implementiert

name - FormBean, die diese Action verwendet

...

die Erzeugung der Objekte übernimmt Struts

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

17

Controller – Action

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Controller

ActionMapping

request

Struts-config

„Controller“ActionServlet

Action

dispatch

18

Controller – Action

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

von Action abgeleitet

dient als Wrapper-Klasse (übersetzt den HTTP-Request für die eigentliche Geschäftslogik )

gibt ein ActionForward Objekt zurück (identifiziert die nächste aufzurufende Seite)

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

ControllerController

19

Model – Komponenten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

ActionForm

Model

Action

JavaBeans

20

Model – JavaBean

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

„normale“ Java Klassen

Beinhalten Geschäftslogik

Unabhängig von der Webanwendung

21

Model – ActionForm

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

erbt von ActionForm

Speicherung der Formulardaten in Variablen

get()- und set()-Methoden

keine Geschäftslogik

22

View – Komponenten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

JSP

View

Properties

Taglibs

ControllerController

ModelModel

forwardget

23

View – JavaServerPage

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

<HTML><HEAD>

<jsp:useBean id=„tBean" scope="session" class=„ToneBean" /><jsp:setProperty name=„tBean" property="*" />

<TITLE>Presentation</TITLE></HEAD><BODY>

<H1> Pr&auml;sentation mit Sound </H1>

<% tBean.retrieveSession(request); %><% if(!tBean.hasSound()){ %><jsp:forward page=„NoSound.jsp"/><% } %>

</BODY></HTML>

<HTML><HEAD>

<jsp:useBean id=„tBean" scope="session" class=„ToneBean" /><jsp:setProperty name=„tBean" property="*" />

<TITLE>Presentation</TITLE></HEAD><BODY>

<H1> Pr&auml;sentation mit Sound </H1>

<% tBean.retrieveSession(request); %><% if(!tBean.hasSound()){ %><jsp:forward page=„NoSound.jsp"/><% } %>

</BODY></HTML>

24

View – JavaServerPage

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

JSP file

<HTML><JSP:Tag>

Tag Library

JSP :TagJava Code

JSP – Umgebung

Standard Action Tags

Custom Tag Libraries

25

View – Taglibs

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Struts-Bean Taglib

Struts-HTML Tagblib

Struts-Logic Taglib

Struts-Template Taglib

26

View – Properties

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

internationalisierte & lokalisierte Anwendungen

Schlüsselkonzepte (Sprache, Formatierung)

Beispiel:

MyResources[_49].properties

Inhalt: Nachrichten in der Standardsprache des Servers

Möglicher Eintrag: prompt.Hallo = Hallo

27

Zusammenspiel der Komponenten

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

Struts-config

Controller

Action

JavaBean

JSPresponse

request

TaglibProperties

ActionMapping

forward

set

get

dispatch

get/set

Modell

View

ActionForm

„Controller“ActionServlet forward

28

Pro – Contra

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Pro

Trennung von Ablauf, Business-Logik und Darstellung

Tag Library

Properties

Open Source

vorgegebene Komponenten

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

29

Pro – Contra

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

Contra

sehr jung

spätere Änderungen im Code nötig

begrenzter Anwendungsbereich

Komplexität

Unterstützung nur über Newsgroups

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen

30

Alternativen

Stefanie Selzer - Pascal Busch - Michael Kropiwoda

KDF

Maverick

Agenda

I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen - Model I - Model II + MVC

II Struts + Framework + Komponenten + Controller - Action Servlet - struts-config.xml - Action Mapping - Action + Model - JavaBeans - Action Form + View - JSP Seite - Taglibs - Properties + Zusammenspiel der Komponenten

III Fazit + Vorteile/Nachteile + Alternativen