Download presentation
Presentation is loading. Please wait.
1
Enterprise/Server-side Java Slide 1j.c.westlake@staffs.ac.uk, edited by NAS Introduction Welcome! As usual the module lasts for 12 weeks with the last week being a revision week. For assessment details let us refer to the module web page. Module leader is Nic Shulver
2
Enterprise/Server-side Java Slide 2j.c.westlake@staffs.ac.uk, edited by NAS Our Contact Point The course schedule details the subject we will be teaching each week as well as the practicals. Books! - so many to choose from - some quite awful - some good. A list of books can be found on the Module Information page. You do not have to buy a book - plenty in the library.
3
Enterprise/Server-side Java Slide 3j.c.westlake@staffs.ac.uk, edited by NAS Other advice Please see or email tutors about any aspect of the module during the 12 weeks. If you have a problem understanding some of the material, then please ask tutors! The slides that follow put “server-side Java for enterprise” in context Note emphasis on key words (orange highlight)
4
Enterprise/Server-side Java Slide 4j.c.westlake@staffs.ac.uk, edited by NAS Java Server Pages Format of lecture: Introduction What are Java Server Pages? (JSPs) What do you need to run JSPs? Demo of an example of a JSP in action Tutorial work will get you going straight away on understanding the architecture and running your first JSP
5
Enterprise/Server-side Java Slide 5j.c.westlake@staffs.ac.uk, edited by NAS Overview/history - 90’s Early web users were limited to static HTML. Useful for presenting company information often in a hierarchical manner. Little or no interaction with the user. Java applets addressed this problem enabling additional code to be downloaded but still a problem of building customised information. Dynamically generated HTML using the Common Gateway Interface (CGI) was also a proposed solution.
6
Enterprise/Server-side Java Slide 6j.c.westlake@staffs.ac.uk, edited by NAS Year 2000 onwards CGI and generated HTML was the forerunner for server-side Java based techniques. Java Servlets. JavaServer Pages (JSP). Component-based computing (Enterprise JavaBeans). Active Server Pages (ASP, ASP.net). Personal Hypertext Preprocessor (PHP)
7
Enterprise/Server-side Java Slide 7j.c.westlake@staffs.ac.uk, edited by NAS Evolution of Applications One-tier - mainframe based/dumb terminal/central application source. Also modern standalone/PC/Mini computers/multi copy of application. What we might think of as a simple, “normal” application.
8
Enterprise/Server-side Java Slide 8j.c.westlake@staffs.ac.uk, edited by NAS Evolution of Applications Two tier - client-server - distributed part of the application on the client (GUI) and part on the server. Early versions of client-server required installation of GUI and business logic. Recently, Java applets downloadable on demand. With server-side servlets and JSP, no download and the browser is used as the interface - this is a good solution!
9
Enterprise/Server-side Java Slide 9j.c.westlake@staffs.ac.uk, edited by NAS Evolution of Applications Three tier/n-tier - user interface(UI) layer; the business layer(BL) and the database layer(DL) UI - presentation of information, browsers such as Firefox or Internet Explorer on the client BL - logic of procedures about the business, best done on a server [why?] DL - where the data is stored - usually a relational database but could be an object oriented database
10
Enterprise/Server-side Java Slide 10j.c.westlake@staffs.ac.uk, edited by NAS Benefits of Web-Enabled n-tier Applications Web applications enable ‘things’ to be done from a web browser - e.g. online banking. Run from anywhere – no installation fee, may incur network communication costs of course. Cost reduction: Browser based interface is easy to use - little training required. Development costs lower as using a standard interface. No permanent installation on the user’s machine. Use of open standards: Maintenance easier. Enhancement of applications easier.
11
Enterprise/Server-side Java Slide 11j.c.westlake@staffs.ac.uk, edited by NAS Web Enabling Techniques How to develop web-based applications? How can a server process multiple requests? Need a fast response! Scalability - HTTP protocol - works in a stateless request-response mode - means it does not bind a server to a client for an inordinate amount of time. Some techniques which can be used to concurrently satisfy thousands of requests.
12
Enterprise/Server-side Java Slide 12j.c.westlake@staffs.ac.uk, edited by NAS Stuff that we need We are going to spend the next four weeks looking at Java Server Pages (JSPs). Just like when using ASP or PHP, we need a server that understands our JSP code. We need an HTTP server which supports JSP. We will use server software called “Tomcat” Tomcat is running on one of our servers: fcet11 You can also download Tomcat for home use and run a server on your home PC
13
Enterprise/Server-side Java Slide 13j.c.westlake@staffs.ac.uk, edited by NAS What are JSPs? They are HTML documents that are interleaved with Java which provides the dynamic content. JSPs are server-side - they accept a request and generate a response (an HTML document). JSP is the next generation on from Servlets - an extension of Servlets with more power and flexibility. JSP is the equivalent of Microsoft’s Active Server Pages (ASP) technology and Zend's PHP environment.
14
Enterprise/Server-side Java Slide 14j.c.westlake@staffs.ac.uk, edited by NAS JSPs… Servlets… ??? JSPs are an extension of Java Servlet technology. JSPs automatically generate Servlets which are Java class files run on the server. It is possible to code your own Servlets and include them in with your JSP web application. A useful source of information for JSPs and Servlet technologies is the Java Server Pages homepage at Sun: http://java.sun.com/products/jsp/index.html
15
Enterprise/Server-side Java Slide 15j.c.westlake@staffs.ac.uk, edited by NAS Facts about JSPs All JSPs have a file extension of.jsp JSP is meant to be easier than Servlets. Syntax of a typical JSP is on the next two slides. Over the next four weeks we will look at the syntax of JSPs in depth.
16
simpleguestlist.jsp An Example of a Simple JSP Accessing a database Model A Listing Of Guests Email Firstname Lastname
17
<% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:odbc:GuestBook"); Statement statement = conn.createStatement(); String sql = "SELECT * FROM GuestBook"; ResultSet rs = statement.executeQuery(sql); while (rs.next()) { %> <% } %> <% if (statement != null) statement.close(); if (conn != null) conn.close(); } catch (Exception e) {out.print(e);} %>
18
Enterprise/Server-side Java Slide 18j.c.westlake@staffs.ac.uk, edited by NAS Kit required What do you need to develop and run JSPs? JDK (Java Development Kit and runtime) Tomcat HTTP server With database interaction we need a database – we will use Access for convenience but MySQL is also of interest
19
Enterprise/Server-side Java Slide 19j.c.westlake@staffs.ac.uk, edited by NAS Demo of a JSP This example is a JSP which uses a DSN-less connection to the GuestBook database The application model is essentially a JSP connecting to a database It renders dynamically to the user’s browser the contents of a table As the table changes the content of the page will reflect this change – hence it dynamic – built at each request
20
Enterprise/Server-side Java Slide 20j.c.westlake@staffs.ac.uk, edited by NAS Example http://fcet11.staffs.ac.uk:8080/nas1/examples/SimpleGuestList.jsp
21
Enterprise/Server-side Java JSP Translation process.jsp file (HTML interleaved with Java) HTTP Server TOMCAT Request:Browser page link to call.jsp(either via locator or a link on an HTML input page Response: HTML for output sent from Server Browser Response HTML document Request: JSP translated into a Servlet.java file and then compiled into a Servlet class Backend database usually on a separate database server Query for data content Browser TierServer TierDatabase Tier
22
Enterprise/Server-side Java Slide 22j.c.westlake@staffs.ac.uk, edited by NAS Result Returned
23
Enterprise/Server-side Java Slide 23j.c.westlake@staffs.ac.uk, edited by NAS Summary We have established that JSP represents a technology that can be used for dynamic web applications The market for this type of technology is well established (J2EE market) JSP demands some programming skills but is more and more seen as an integration technology with can dovetail with technologies such as XML
24
Enterprise/Server-side Java Slide 24j.c.westlake@staffs.ac.uk, edited by NAS Summary We used an HTTP server which supports JSP If you were choosing an ISP and wished to run JSP then you would need to check that they support JSP We highlighted the features of a JSP A.jsp file is essentially HTML with Java code inserts When the.jsp file is called via a browser a.java file is created to represent Servlet source code and then the.java file is compiled into a bytecode file with a.class extension. The compilation is only done once - subsequent calls to the JSP use the already compiled.class file
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.