Exploring Dynamic Web Development with Servlets and JSP
300 likes | 376 Vues
Learn about Servlets, JSP, MVC, Struts framework, components, controllers, and views. Understand the interaction between components with advantages, disadvantages, and alternatives.
Exploring Dynamic Web Development with Servlets and JSP
E N D
Presentation Transcript
Agenda I Einleitung + Dynamische Seiten + Servlets + JSP Architekturen + MVC II Struts + Framework + Komponenten + Controller + Model + View + Zusammenspiel der Komponenten III Fazit + Vorteile/Nachteile + Alternativen 2 Stefanie Selzer - Pascal Busch - Michael Kropiwoda
request request response response 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 Dynamische Seiten Applikation Web Server Br o w s e r Dynamische Seite 3 Statische Seite Data Sources Stefanie Selzer - Pascal Busch - Michael Kropiwoda
Enterprise Server request response 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 Servlet • serverseitige Java-Komponente • verschiedene Ausgabeformate möglich 4 Web Server Client Servlet Data Sources Stefanie Selzer - Pascal Busch - Michael Kropiwoda
request response 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 Model I Enterprise Server Web Server Br o w s e r JSP Seite 5 JavaBean Data Sources Stefanie Selzer - Pascal Busch - Michael Kropiwoda
request instantiiert response 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 Model II Enterprise Server Web Server Br o w s e r Controller 6 JSP Seite JavaBean Data Sources 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 MVC Controller 7 User Model View 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 Framework • Vorgefertigte Anwendungskomponenten • Vorgegebene Architektur • Plattformunabhängigkeit • Ziele: Schnellere Entwicklungszeiten • Bessere Abbildung der Prozesse 8 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 – Komponenten Web Server • Controller • Action Servlet • Action Mapping/Action Forward • struts-config.xml • Action 9 • View • JSP Seite • Taglibs • Properties • Model • Java Beans • 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 Controller – Komponenten • die Klasse ActionServlet • die Datei struts-config.xml • die Klasse ActionMapping • die Action-Klassen 10 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 – ActionServlet • 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) 11 Stefanie Selzer - Pascal Busch - Michael Kropiwoda
Struts- config request 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 – struts-config.xml Controller „Controller“ ActionServlet 12 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 – struts-config.xml 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> 13 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 – struts-config.xml <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> 14 Stefanie Selzer - Pascal Busch - Michael Kropiwoda
request ActionMapping 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 Controller Struts- config „Controller“ ActionServlet 15 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 • 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 16 Stefanie Selzer - Pascal Busch - Michael Kropiwoda
request dispatch Action 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 – Action Controller Struts- config „Controller“ ActionServlet 17 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 – Action • 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) 18 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 Model – Komponenten Controller Action Model 19 ActionForm JavaBeans 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 Model – JavaBean • „normale“ Java Klassen • Beinhalten Geschäftslogik • Unabhängig von der Webanwendung 20 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 Model – ActionForm • erbt von ActionForm • Speicherung der Formulardaten in Variablen • get()- und set()-Methoden • keine Geschäftslogik 21 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 – Komponenten Controller Model forward get 22 View Taglibs JSP 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 View – JavaServerPage <HTML> <HEAD> <jsp:useBean id=„tBean" scope="session" class=„ToneBean" /> <jsp:setProperty name=„tBean" property="*" /> <TITLE> Presentation </TITLE> </HEAD> <BODY> <H1> Präsentation mit Sound </H1> <% tBean.retrieveSession(request); %> <% if(!tBean.hasSound()){ %> <jsp:forward page=„NoSound.jsp"/> <% } %> </BODY> </HTML> 23 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 – JavaServerPage JSP file <HTML> <JSP:Tag> Tag Library JSP :Tag Java Code 24 • JSP – Umgebung • Standard Action Tags • Custom Tag Libraries 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 – Taglibs • Struts-Bean Taglib • Struts-HTML Tagblib • Struts-Logic Taglib • Struts-Template Taglib 25 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 – Properties • internationalisierte & lokalisierte Anwendungen • Schlüsselkonzepte (Sprache, Formatierung) Beispiel: MyResources[_49].properties Inhalt: Nachrichten in der Standardsprache des Servers Möglicher Eintrag: prompt.Hallo = Hallo 26 Stefanie Selzer - Pascal Busch - Michael Kropiwoda
Struts- config request ActionMapping forward dispatch set get/set forward get Taglib response Properties 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 Zusammenspiel der Komponenten Controller „Controller“ ActionServlet Action 27 Modell ActionForm JavaBean View JSP 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 Pro – Contra • Pro • Trennung von Ablauf, Business-Logik und Darstellung • Tag Library • Properties • Open Source • vorgegebene Komponenten 28 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 Pro – Contra • Contra • sehr jung • spätere Änderungen im Code nötig • begrenzter Anwendungsbereich • Komplexität • Unterstützung nur über Newsgroups 29 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 Alternativen • KDF • Maverick 30 Stefanie Selzer - Pascal Busch - Michael Kropiwoda