Chapter #1. Applet: Java prgram that are typically embedded in XHTML dcuments. life-cycle methds: 1. init(): called nce by the applet cntainer when an applet is laded fr executin. 2. start(): Called by the applet cntainer after methd init() cmpletes executin. This methd perfrms any tasks that must be perfrmed when the applet is laded. 3. paint(): Called by the applet cntainer after methds init() and start(). Methd paint() is als called when the applet needs t be repainted. 4. stp(): called by the applet cntainer when the user leaves the applet's web page by brwsing t anther web page. 5. destry(): called by the applet cntainer when the applet is being remved frm memry. This ccurs when the user exits the brwsing sessin by clsing all the brwser windws. Applet Cntainers: the applicatin in which the applet executes is knwn as the applet cntainers. Such as (applet viewer). init() stp() destry() start() paint(graphics) Summarized by Faisal Fagihi 1 12/18/2018
Chapter #2. Swing Cmpnents Mst Swing GUI cmpnents are lcated in package javax.swing. Swing GUI cmpnents allw yu t specify a unifrm lk- and-feel fr yur applicatin acrss all platfrms r t use each platfrm s custm lk-and-feel. Cmpnent JLabel JTextField JButtn JCheckBx JCmbBx JList JPanel Descriptin Displays undatable text and/r icns. Typically receives input frm the user. Triggers an event when click the muse. Specifies an ptin that can be selected r nt selected. A drp-dwn list f items. A list f items; multiple elements can be selected An area in which cmpnents can be placed and rganized. Awt vs Swing package AWT SWING slw heavy weigth mre memry space java.awt package features nt supprted fast light weigth swing less memry space javax.swing package features supprted Lightweight vs Heavyweight Lightweight Swing cmpnents are nt tied t actual GUI cmpnents supprted by the under- lying platfrm n which an applicatin executes. Several Swing cmpnents are heavyweight cmpnents that require direct interactin with the lcal windwing system which may restrict their appearance and functinality. Cmmn superclasses f the lightweight Swing cmpnents. Summarized by Faisal Fagihi 2 12/18/2018
Event Handling: GUI are event driven. When the user interacts with a GUI cmpnent, the interactin knwn as an event The cde that perfrms a task in respnse t an event is called an event handler. the verall prcess f respnding t events is knwn as event handling. Steps t Set Up Event Handling: 1. Create a class that represents that event handler. 2. Implement an apprpriate interface, knwn as an event-listener interface, in the class frm Step1. 3. Indicate that an bject f the class frm Steps1 and 2 shuld be ntified when the event ccurs. This is knwn as registering the event handler. Imprtant parts t the event- handling mechanism. event surce: It is the GUI cmpnent with which the user interacts. event bject: The event bject encapsulates infrmatin abut the event that ccurred, such as a reference t the event surce and any event-specific infrmatin that may be required by the event listener fr it t handle the event. event listener: is an bject that is ntified by the event surce when an event ccurs; in effect, it listens fr an event, and ne f its methds executes in respnse t the event. A methd f the event listener receives an event bjects when the event listener is ntified f the event. The event listener then uses the event bject t respnd t the event. This event handling mdel is knwn as the delegatin event mdel. Summarized by Faisal Fagihi 3 12/18/2018
Chapter #3. Layut manager: is an instance f any class that implements the LayutManager interface. The layut manager is set by the setlayut() methd. FlwLayut BrderLayut GridLayut CardLayut GridBagLayut FlwLayut: is the default layut manager. by default, cmpnents are laidut line-by-line beginning at the upper-left crner. Alignment: FlwLayut.LEFT FlwLayut.CENTER(default) FlwLayut.RIGHT Brder Layut: implements a cmmn layut.style fr tp-level windws, It has fur narrw, fixed-width cmpnents at the edges and ne large area in the center. BrderLayut defines the fllwing cnstants that specify the regins. BrderLayut.CENTER BrderLayut.EAST BrderLayut.NORTH BrderLayut.SOUTH BrderLayut.WEST GridLayut: It lays ut cmpnents in a tw-dimensinal grid. The cnstructrs supprted by GridLayut are shwn here. GridLayut() GridLayut(int numrws, int numclumns) GridLayut(int numrws, int numclumns, int hrz, int vert) CardLayut: is unique amng the ther Managers in that it stres several different layuts. CardLayut prvides these tw cnstructrs: Cardalyut() CardLayut (int hrz, int vert) GridBagLayut: is a bit mre cmplicated than the ther layut managers, it is still quite easy t use nce yu understand hw it wrks. Summarized by Faisal Fagihi 4 12/18/2018
Chapter #4. JDBC drivers: implement the defined interfaces in the JDBC API fr interacting with yur database server. Steps fr Cnnectin 1. Lading Driver 2. Establishing Cnnectin 3. Preparing Statements 4. Executing Statements 5. Getting Results 6. Clsing Database Cnnectin JDBC Drivers Types: JDBC-ODBC Bridge Driver: using ODBC requires cnfiguring n yur system a Data Surce Name (DSN) that represents the target database. JDBC-Net pure Java: the JDBC clients use standard netwrk sckets t cmmunicate with a middleware applicatin server. JDBC-Native API: calls are cnverted int native C/C++ API calls which are unique t the database. 100% pure Java: cmmunicates directly with vendr's database thrugh scket cnnectin. Summarized by Faisal Fagihi 5 12/18/2018
Chapter #5. javax.servlet package cntains a number f interfaces and classes that establish the framewrk in which servlets perate. The Servlet interface: Servlet interface has the fllwing lifecycle methds: Init (ServletCnfig as). Service (ServletRequest req, ServletRespnse res). destry(). The ServletRequest interface: enables a servlet t btain infrmatin abut a client request. The ServletRespnse interface: enables a servlet t frmulate a respnse fr a client. Reading Servlet Parameter: includes methds that allw yu t read the names and values f parameters that are required in a client request. javax.servlet.http package: cntains a number f interfaces and classes that are cmmnly used by servlet develpers. javax.servlet.http package Interface: HttpServletRequest: enables servlets t read data frm an HTTP request. HttpServletRespnse: enables servlets t write data t an HTTP respnse. HttpSessin: allws sessin data t be read and written. javax.servlet.http package Classes: Ckie: allws state infrmatin t be stred n a client machine. HttpServlet: prvides methd t handle HTTP Requests and respnses. HttpSessinEvent: encapsulates a sessin-changed event. HTTP Requests and Respnses: service(servletrequest, ServletRespnse) dget(httpservletrequest, ServletRespnse) dpst(---------------------,---------------------) ddelete(------------------,---------------------) dput(-----------------------,---------------------) dtrace(--------------------,----------------------) dhead(---------------------,----------------------) doptins(------------------,----------------------) Summarized by Faisal Fagihi 6 12/18/2018
Applet vs Servlet Applet client-side prgram static page runs in a web brwser use the user Interface classes single thread Servlet server-side prgram dynamic page runs n the web server servlet desn t have a user Interface Multithreaded dget( ) vs dpst( ) dget( ) dpst( ) request is submitted via URL insecure limited data can be used as a bkmark idemptent request is submitted via frm secure unlimited data cannt be used as a bkmark nt idemptent Summarized by Faisal Fagihi 7 12/18/2018
Chapter #6. JavaServer page (JSP): is a template fr a Web page that uses Java cde t generate an HTML dcument dynamically. JSPs are run in a server-side cmpnent knwn as a JSP cntainer, which translates them int equivalent Java servlets. JSPs advantages better perfrmance and scalability than CGI scripts. N special client setup is required. autmatically recmpiled when necessary. addressing JSP pages is simpler than addressing servlets. greater cmpatibility with Web develpment tls. Hw JSP Wrks JSP page exists in three frms: JSP surce cde: is the frm the develper actually writes. Java surce cde: the JSP cntainer translates the JSP surce cde int the surce cde fr an equivalent Java servlet as needed. Cmpiled Java class: the generated servlet cde is cmpiled int byte cdes in a.class file, ready t be laded and executed. Summarized by Faisal Fagihi 8 12/18/2018
Cmpnents f a JSP Page JSP elements are instructins t the JSP cntainer abut what cde t generate and hw it shuld perate. Have 3 types: 1. Directives (Page Include Taglib) 2. Scripting elements (expressins scriptlets - declaratins) 3. Actins Template data is everything else that is nt recgnized by the JSP cntainer. Page Directive syntax: <%@ page [attribute="value" attribute="value"...] %> attributes: language, buffer, imprt, sessin. Include Directive syntax: <%@ include file="filename" %> Taglib syntax: <%@ taglib uri="taglibraryuri" prefix="tagprefix" %> attributes: taglibraryuri, tagprefix. Expressins syntax: <%= exp %> Scriptlets: a set f ne r mre Java language statements intended t be used t prcess an HTTP request. syntax: <% statement; [statement;...] %> Declaratins: is incrprated int the generated surce file utside the _jspservice()methd. syntax: <%! statement; [statement;...] %> Standard Actins: are high-level JSP elements that create, mdify, r use ther bjects. syntax: tagname [attr="value" attr="value"...] >... </tag-name> Summarized by Faisal Fagihi 9 12/18/2018