Servlets, JSPs and MySQL Presented by: Gian Alvarez Vicente Rivera.

21
Servlets, JSPs and Servlets, JSPs and MySQL MySQL Presented by: Gian Alvarez Vicente Rivera

Transcript of Servlets, JSPs and MySQL Presented by: Gian Alvarez Vicente Rivera.

  • Servlets, JSPs and MySQL Presented by: Gian Alvarez Vicente Rivera

  • AgendaOverview of JSPJSP ArchitectureProviders of JSP Server EnginesWho is Using JSPCompare JSP to Other ToolsPros and Cons of JSPJAVA BeansExamplesMini-WorkshopLinks/Questions

  • JSP Overview - HistoryEarlier dynamic web pages were developed with CGIWeb Applications eventually outgrew CGI because of the following:Datasets became largeIncreased traffic on sitesTrouble maintaining state and session informationPerformance bottlenecksCan involve proprietary APIs

  • JSP Overview History (Contd)Microsoft Saves the Day?Active Server Pages (ASP) are released that are:Pre-coded server extensionsEasily integrates with ODBCGives developers simple server-side scripting to access the serverUpside for Microsoft, downside for us, ASP is limited to only Microsoft platforms

  • JSP Overview - SoftwareWith a foundation in Java, JSPThreads incoming requestsSupports the definition of tags that abstract functionality within a page in a libraryInteracts with a wide array of databasesServes dynamic content in a persistent and efficient manner Initially the server automatically separates HTML and JSP code, compiles the JSP code, and starts the servlet, from then on the servlets are stored in the web servers memory in Java byte codeExtends the same portability, large class library, object-oriented code methodology, and robust security measures that have made Java a top choice

  • Architecture

  • Who is using JSP?altavista.comhttp://www.altavista.com half.comhttp://www.half.comE-Loan http://www.e-loan.comiWonhttp://www.iwon.comJguruhttp://www.jguru.comState of Maine http://www.state.me.us

    petsmart.comhttp://www.petsmart.com ya.comhttp://www.ya.comBizRatehttp://www.bizrate.comsalesforce.comhttp://www.salesforce.comlisten.comhttp://www.listen.comState of Utah http://www.state.ut.us

  • Comparison of JSP to

  • Comparison of JSP to (Contd)

  • Pros and ConsProsEfficientConvenientServer engines typically have built-in infrastructures to handle parsing/decoding HTML form data, reading/setting HTTP headers, session trackingPowerfulJava behind the scenePortableWrite once, run anywhereInexpensiveVarious free or inexpensive engines available

    ConsNeed for a Server EngineAnother engine to maintainUn-acceptably by the client machineVirtual hosting of unrelated sites on a single machine can cause problems (choose your server engine wisely)High Learning CurveSteeper learning curve than Cold Fusion

  • JSP and JavaBeansA JavaBean is a Java Class file that creates an objectDefines how to create an Object, retrieve and set properties of the Object

    JSPJavaBeansGet Bean ValueSet Bean Value

  • JSP and JavaBeans (Contd)JavaBeans can store dataJavaBeans can perform complex calculationsJavaBeans can hold business logicJavaBeans can handle Database Connectivity and store data retrieved from themJavaBeans facilitateReuse of codeDebugging processSeparating code from content

  • ExamplesHello World

    Hello1.jsp

    Hello World

    The browser displays: Hello World

  • ExamplesRectangle Problem

  • ExamplesRandom Numbers

  • ExamplesRandom Numbers (Contd)The browser displays:Your Personal Random NumbersHere are your personal random numbers: 1.524033632 2.-1510545386 3.1167840837 4.-850658191 5.-1203635778

  • Mini - Workshop

  • Mini - Workshop

  • ER-Diagram

  • Some Good LinksJguru.comhttp://www.jguru.com - main page has nice search of the FAQ, Forums, etchttp://www.jguru.com/faq/JSP their main JSP FAQ pageJspinsider.comhttp://www.jspinsider.com - articles, tutorials, linkshttp://www.jspinsider.com/content/rcarnes/jspb_intro.view - on-line course/tutorial on JSPOther Tutorialshttp://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ basis of the book Core Servlets and JavaServer Pages (Sun Microsystems Press and Prentice Hall, May 2000) by Marty HallSuns Java Site JSPForum active http://forum.java.sun.com/forum.jsp?forum=45 archive-http://archives.java.sun.com/archives/servlet-interest.htmlSuns Java Site APIsJava Std Ed http://java.sun.com/j2se/1.3/docs/api/index.html essential javaJava Enterprise Edition http://java.sun.com/j2ee/j2sdkee/techdocs/api/index.html enterprise-class server side applications

  • Questions?