Java web hosting at CERN Computing Seminar, 1 November 2005 Michał Kwiatek, IT-DES.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Servlets and Java Server Pages.
Advertisements

5 Copyright © 2005, Oracle. All rights reserved. Accessing the Database with Servlets.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
JSP and web applications
Servlets, JSP and JavaBeans Joshua Scotton.  Getting Started  Servlets  JSP  JavaBeans  MVC  Conclusion.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Cluster architecture for Java web hosting at CERN CHEP 2006, Mumbai Michał Kwiatek, CERN IT Department Database and Engineering Services Group.
Model-View-Controller ("MVC") This is a architectural design pattern for interactive applications. This design pattern organizes an interactive application.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
JDBC Dr Jim Briggs. WEBP JDBC2 JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets) to databases Largely.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
An introduction to Java Servlet Programming
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Core Servlets Chapter 3 Link for Core Servlets code: om/archive/ om/archive/
JDBC Data source and Connection pooling 1 JDBC Data sources and Connection pooling.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Basic JDBC Use Oracle JDBC Drivers must be in the CLASSPATH
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets and JSP.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Java Servlets CS-422. Application Mapping Your servlet application will be mapped to a directory structure: –“myapp” maps to some directory C:/docs/apps/myapp.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
Objectives Java Servlet Web Components
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Java Servlets and Java Server Pages Carol Wolf Computer Science.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
Li Tak Sing COMPS311F. Static attributes in Servlets Since Servlets are also Java classes, you can also use static attributes to store values that can.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
JSP Most of the web developers deploying web applications using servlets mixes the presentation logic and business logic. Separation of business logic.
Chapter 5 Being a Web App. Very few servlet or JSP stands alone Many times in our application, different servlets or JSPs need to share information 
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
1 JDBC Resource Registration on WebSphere Console javax.naming.InitialContext ctx = new javax.naming.InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/DB2UDB");
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
Java Servlets & Java Server Pages Lecture July 2013.
CS 160: Software Engineering October 1 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Writing Enterprise Applications with J2EE (Fourth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.
Leman Akoglu 11/11/ Fall 2009 Recitation Homework 9 Building A Web Application Phase-II School of Computer Science.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
1 Download current version of Tomcat from: g/tomcat/ g/tomcat/ Install it in: C:\Program Files\Apache.
JSP Java Server Pages. Hello, !
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Java web hosting at CERN
Java Servlets By: Tejashri Udavant..
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Objectives In this lesson you will learn about: Need for servlets
Presentation transcript:

Java web hosting at CERN Computing Seminar, 1 November 2005 Michał Kwiatek, IT-DES

2 What we’ll be doing A few words about servlets and JSPs How to deploy them at CERN Scope, SLA and architecture of J2EE Public Service Some „advanced” examples

Michał Kwiatek, IT-DES3 What is a JSP? Age example <% String yearString = request.getParameter("year"); int year; if (yearString==null || yearString.equals("")) { out.print("Please specify your year of birth using year parameter"); } else { try { year = new Integer(yearString).intValue(); %>You are years old.<% } catch (NumberFormatException e) { %> Year of birth incorrect! <% } %>

Michał Kwiatek, IT-DES4 JSP implicit variables request session application response out

Michał Kwiatek, IT-DES5 What is a servlet? A java class that lives inside web container to serve client requests extends javax.servlet.http.HttpServlet defining one or more of the following methods: –doGet –doPost –doPut –doDelete –service –init –destroy Note: the same servlet object will be used simultaneously to serve many request!

Michał Kwiatek, IT-DES6 Your servlets should be thread-safe! package ch.cern.example; import... public class ServletA extends HttpServlet { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); public void service (HttpServletRequest request, HttpServletResponse response) { response.write("Current date and time is: "); response.write(sdf.format(new Date())); } Javadoc: Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.

Michał Kwiatek, IT-DES7 JSP is a servlet! Welcome, you are visitor number Declaration! package ch.cern.example; import... public class MyServlet extends HttpServlet { int count = 0; public void service (HttpServletRequest request, HttpServletResponse response) { response.write(" Welcome, you are visitor number"+(++count)+" "); }

Michał Kwiatek, IT-DES8 Did you make a nice jack’o lantern?

Michał Kwiatek, IT-DES9 There’s more to JSP than just the pages Object-oriented programming Java libriaries, java beans Custom tag libraries Model-View-Controler model Java Server Faces It is vendor and platform independent

Michał Kwiatek, IT-DES10 How to deploy them at CERN? Go to CERN Web Service: Choose „java web application (servlet/jsp)” as site type

Michał Kwiatek, IT-DES11 So what is this WAR file? WAR file is simply a zip archive with a specific structure jar files go to WEB-INF/lib classes go to WEB-INF/classes Application configuration files The rest is regular web content Use your IDE or Ant to package your application

Michał Kwiatek, IT-DES12 J2EE Public Service server-side infrastructure for deployment of java (servlet/jsp) web applications provided by IT-DES we provide: –servlet/JSP container –support for deployment –backup, monitoring we don’t provide: –an EJB container –support for development –telnet/ssh/ftp access to the servers SLA: aimed for medium-sized, non-critical applications; full support within CERN working hours; the support outside working hours is provided on best effort basis.

Michał Kwiatek, IT-DES13 „Standard” approach !

Michał Kwiatek, IT-DES14 J2EE Public Service - approach !

Michał Kwiatek, IT-DES15 J2EE Public Server architecture software used: –Apache Tomcat 5.5 –JDK 1.5 –Apache httpd 2.0 –jpsmanager The architecture is open!

Michał Kwiatek, IT-DES16 Guess what! JDBC drivers to oracle are preinstalled (thin) 3 usage scenarios

Michał Kwiatek, IT-DES17 JDBC Connection conn = null; Statement stmt = null; ResultSet rset = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection(url, user, password); stmt = conn.createStatement(); rset = stmt.executeQuery(query);... } catch(SQLException e) {... } finally { try { rset.close(); } catch(Exception e) { } try { stmt.close(); } catch(Exception e) { } try { conn.close(); } catch(Exception e) { } } 1. Basic example 2. Connection pooling

Michał Kwiatek, IT-DES18 JDBC (cont’d) // in Servlet, JSP, or simply a class: Connection conn = null; Statement stmt = null; ResultSet rset = null; try { Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/devdb"); conn = ds.getConnection(); stmt = conn.createStatement(); rset = stmt.executeQuery(query);... } catch(SQLException e) {... } finally { try { rset.close(); } catch(Exception e) { } try { stmt.close(); } catch(Exception e) { } try { conn.close(); } catch(Exception e) { } } 3. Connection pooling & JNDI (1/2)

Michał Kwiatek, IT-DES19 JDBC (cont’d) // in META-INF/context.xml: <Resource name="jdbc/devdb" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver" username="XXXXX" password="XXXXX" maxActive="10" maxIdle="5" /> // in WEB-INF/web.xml: Connection pooling & JNDI (2/2)

Michał Kwiatek, IT-DES20 Authentication/authorisation Authentication: –my identity can be confirmed using my CERN id card Authorisation –using my identity and additional information (did I attend the security course?) the system will let me into the Computer Centre or not

Michał Kwiatek, IT-DES21 How to do it NICEly? method for authentication and authorisation –is provided by the container –uses existing mechanisms this method is NICE: –NICE login and password to authenticate –NICE groups to authorise (CERN Department/Group structure, or some project-specific groups)

Michał Kwiatek, IT-DES22 NICE authentication NICE authentication is set up by default in WEB-INF/web.xml you specify which areas of your application require authenticationWEB-INF/web.xml you also specify which groups of users are authorized to access these areas you can define these groups (and their members) at from your application, you may check who is logged on using: request.getUserPrincipal()

Michał Kwiatek, IT-DES23 Resources service/ service/ –sla.html –faq.html –technical.html chapter 9, "Developing secure web applications" from SCWCD Exam Study Kit by Hanumant Deshmukh and Jignesh Malavia. SCWCD Exam Study Kit by Hanumant Deshmukh and Jignesh Malavia datasource-examples-howto.htmlhttp://tomcat.apache.org/tomcat-5.5-doc/jndi- datasource-examples-howto.html j2ee tutorial: x.html x.html

Michał Kwiatek, IT-DES24 Questions?