2/16/2004 Dynamic Content February 16, 2004. 2/16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.

Slides:



Advertisements
Similar presentations
Java Servlets Java Server Pages (JSP)
Advertisements

Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets Stoney Jackson
An introduction to Java Servlet Programming
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
Core Servlets Chapter 3 Link for Core Servlets code: om/archive/ om/archive/
1 CS6320 – Servlet Structure and Lifecycle L. Grewe.
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
Java database Programming JDBC Trademarked name of a Java API that supports Java programs that access relational databases Stand for Java DataBase Connectivity.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
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.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Servlets, Sessions, and Cookies Lecture 8 cs193i – Internet Technologies Summer 2004 Kelly Shaw, Stanford University.
Java Servlet Technology. Introduction Servlets are Java programs that run on a Web server, handle HTTP requests and build Web pages Servlet specification.
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
Objectives Java Servlet Web Components
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
CSC 2720 Building Web Applications
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
SKT-SSU IT Training Center Servlet and JSP. Chapter Three: Servlet Basics.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
COMP201 Java Programming Part III: Advanced Features Topic 14: Servlets Servlets and JavaServer Pages (JSP) 1.0: A Tutorial
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
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.
Java Servlets & Java Server Pages Lecture July 2013.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
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.
Saving Client State Session Tracking: Maintain state about series of requests from same client over time Using Cookies: Clients hold small amount of their.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
S ERVLETS Hits Counter 21-Nov-15. S ERVLETS - H ITS C OUNTER Many times you would be interested in knowing total number of hits on a particular page of.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
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, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Java Servlets Java Server Pages (JSP)
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
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,
Java Web Applications. WAR Web Archive Introduced with servlet 2.2 specification Portable deployment mechanism for web applications Defines directory.
S ERVLETS Form Data 19-Mar-16. F ORM P ROCESSING You must have come across many situations when you need to pass some information from your browser to.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Java Servlets References: Karen Anewalt, Mary Washington College.
Introduction to Servlets
Java Servlets By: Tejashri Udavant..
Net-centric Computing
JDBC & Servlet CSE 4504/6504 Lab.
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Pre-assessment Questions
Servlets CEN /28/2018 Copyright 2001 Ege Consulting, Inc.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Presentation transcript:

2/16/2004 Dynamic Content February 16, 2004

2/16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day

2/16/2004 What is Dynamic Content? Example? Instead of fixed content, generate the page dynamically Run a program and return the result

2/16/2004 Technologies Servlets CGI PHP ASP JSP

2/16/2004 How it Works 1. request

2/16/2004 How it Works 2. “Web container” activates servlet

2/16/2004 How it Works 3. Servlet contacts DB

2/16/2004 How it Works 4. Servlet constructs response and passes to “Web container”

2/16/2004 How it Works 5. Response returned to client

2/16/2004 How it Works mysql Tomcat running on napa Client running web browser

2/16/2004 Developing Servlets 1.Write the Java code – this can happen anywhere, but to compile you need the appropriate jars (servlet.jar, mysql.jar) 2.Put your.class files in the appropriate location Tomcat will look in /home/ /public_html/WEB- INF/classes Make sure WEB-INF has a web.xml 3.Invoke by going to: /servlet/HelloServlet Note, Tomcat using SSL

2/16/2004 HelloServlet.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloServlet extends HttpServlet { public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // set content-type header before accessing the Writer response.setContentType("text/html"); response.setBufferSize(8192); PrintWriter out = response.getWriter(); out.println(" Hello "); out.println(" "); out.println(" Hello Servlet "); out.println(" This is my cool Hello Servlet! "); out.println(" "); out.close(); }

2/16/2004 Servlet Methods init –Called when a servlet is first loaded –Initialize objects (such as DB handle) doGet, doPost –Handle corresponding HTTP request

2/16/2004 Sessions Keep track of multiple accesses by same user –Avoid login at every screen Implementation: Cookies –Store ID mapping in Cookie and keep DS with ID to Object mappings Implementation: URL rewriting –Append ID to all URLs Session API

2/16/2004 Request Methods String getParameter(String name) –Parameter for URL or form data HttpSession getSession()

2/16/2004 Session Methods Object getAttribute(String name) void setAttribute(String name, Object value) void invalidate()

2/16/2004 Response Methods ServletOutputStream getOutputStream() void setContentType(String type) String encodeURL(String URL)

2/16/2004 Example Welcome.java

2/16/2004 Using JDBC Allows you to connect to the mysql database from within a java program (servlet) init method of first servlet (then store in session) Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection = DriverManager.getConnection("jdbc:mysql://localhost/srollins?user= srollins&password=srollins");

2/16/2004 SQL use database username; create table student (firstname VARCHAR(20), lastname VARCHAR(20), password VARCHAR(20), STUID INT NOT NULL PRIMARY KEY); create table course (department VARCHAR(20), number INT, title VARCHAR(20), COURSEID VARCHAR(20)); create table reg_entry (STUID INT, COURSEID VARCHAR(20));

2/16/2004 SQL LOAD DATA local INFILE "student.txt" into table student fields terminated by ':'; student.txt Sami:Rollins:samipw:12345: Mickey:Mouse:mickeypw:12346: course.txt Computer Science:341:Networked Systems:cs341: Computer Science:101:Intro to C:cs101 reg_entry.txt 12345:cs341: 12345:cs101

2/16/2004 SQL SELECT * FROM student where STUID=12345; select course.* from course left join reg_entry on course.COURSEID=reg_entry.COURSEID where reg_entry.STUID=12345; delete from reg_entry where COURSEID='cs101' and STUID=12345; insert into reg_entry (STUID, COURSEID) values (12345, 'cs101');

2/16/2004 JDBC Connection –createStatement Statement –executeQuery – select –executeUpdate – insert/delete ResultSet –next – very important –getString – DB column name (STUID)

2/16/2004 Form Input/DB Interaction Login.java