1 Web Applications – The Basics. 2 Unzipped Tomcat Folder.

Slides:



Advertisements
Similar presentations
Servlets, JSP and JavaBeans Joshua Scotton.  Getting Started  Servlets  JSP  JavaBeans  MVC  Conclusion.
Advertisements

Java Server Pages (JSP)
J.Sant Servlets Joseph Sant Sheridan Institute of Technology.
Servlets Stoney Jackson
1 Web Applications – The Basics (Part 2). 2
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
27-Jun-15 Directories and DDs. 2 Web apps A web application is basically a web site that: “Knows who you are”--it doesn’t just give you static pages,
14-Jul-15 Tomcat. 2 The Apache Jakarta Project The Apache Jakarta Project “creates and maintains open source solutions on the Java platform for distribution.
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.
CS 160: Software Engineering August 27 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Java Servlets and JSP.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Functionality of a web server What does the web server do? Let a user request a resource Find the resource Return something to the user The resource can.
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.
Introduction to Java Server Pages (JSPs) Robert Thornton.
CS 112 Introduction to Programming Web Programming: Backend (server side) Programming with Servlet, JSP Yang (Richard) Yang Computer Science Department.
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
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 Lec 27. Creating a Simple Web Application in Tomcat.
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
Topic Java EE installation (Eclipse, glassfish, etc.) Eclipse configuration for EE Creating a Java Web Dynamic Project Creating your first servlet.
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.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
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.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Core basic Java web server technologies. Tools Eclipse IDE for Java EE Developers (Netbeans also works) nloads/packages/eclipse-
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java and the Web CSE 3330 Southern Methodist University.
Java Servlets and Java Server Pages
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Introduction To HTML Dr. Magdi AMER. HTML elements.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 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,
JSP JavaServer Pages. What is JSP? Java based technology that simplifies the development of dynamic web sites JSP pages are HTML pages with embedded code.
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
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.
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 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Comparative Display Technologies.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
SharePoint & jQuery. About me Phill Duffy – Product Manager at Lightning Tools Ltd – Author of ‘Pro SharePoint with jQuery’ – MCTS Application Developer.
CS122B: Projects in Databases and Web Applications Spring 2017
CS3220 Web and Internet Programming Introduction to Java Servlets
CS122B: Projects in Databases and Web Applications Winter 2017
Building Web Apps with Servlets
Tek Raj Chhetri Code for Humans not for machine.
Google Web Toolkit Tutorial
Platform as a Service Applications
Course Outcomes of Advanced Java Programming AJP (17625, C603)
In Class Assg 4 - Solution
In Class Assg 3 - Solution
CS122B: Projects in Databases and Web Applications Winter 2018
In Class Assg 2 - solution
CS122B: Projects in Databases and Web Applications Spring 2018
Java Servlets and JSP.
CS3220 Web and Internet Programming Introduction to Java Servlets
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Introduction to Java Servlets
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Basic servlet structure
Presentation transcript:

1 Web Applications – The Basics

2 Unzipped Tomcat Folder

3 Environment variables CATALINA_HOME=d:\tools\tomcat PATH –Add d:\tools\tomcat\bin startup.bat shutdown.bat

4 Default Page

5

6 Text File: webapps/abc/f1.txt Hi There

7 f2.html

8 HTML file: webapps/abc/f2.html This is a headline Some text bold, italics, underline A new paragraph, with a link to the first page.

9 f3.html

10 Javascript: webapps/abc/f3.html Click me! some text... $(document).ready(function() { $("#xy256").click(function() { alert("Current time is " + new Date()); });

11 f4.html

12 More Javascript: f4.html N: Compute! $(document).ready(function() { $("#compute").click(function() { var v = $("input").val(); v = parseInt(v)*2; $("#output").html("N*2= " + v + " "); });

13 Sending Data

14 f5.html $(document).ready(function() { $("#compute").click(function() { var v = $("input").val(); location.assign(location.protocol + "//" + location.host + "/abc/f6.html ?input=" + v ); }); What is your name? Welcome!

15 f6.html $(document).ready(function() { // Cuation: Hack ahead. // Use a standard parameter parsing library instead var s = "input="; var i = location.search.indexOf(s); if(i >= 0) { var input = location.search.substring(i + s.length); $("#output").html(input); } }); Nice to see you,

16 So far, we saw… Static (hard coded) pages Some HTML elements Reactive pages – Thanks to Javascript Sending data between pages

17 Dynamic Server Content: d1.html

18 webapps/abc/WEB-INF/web.xml <web-app xmlns=" xmlns:xsi=" xsi:schemaLocation=" version="2.5"> S1 p1.S1 S1 /d1.html

19 Source code: S1.java package p1; import java.io.IOException; import java.util.Date; import javax.servlet.http.*; // // IMPORTANT: Needs servlet-api.jar in order to compile! // Can be found at /lib // public class S1 extends HttpServlet { private static final long serialVersionUID = protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/html"); resp.setCharacterEncoding("UTF-8"); resp.getWriter().println(" Current time " + new Date() + " "); }

20 webapps/abc/WEB-INF/classes

21 Sending Data – to the Server

22 webapps/abc/WEB-INF/web.xml <web-app xmlns=" xmlns:xsi=" xsi:schemaLocation=" version="2.5"> S1 p1.S1 S1 /d1.html S2 p1.S2 S2 /d2.html

23 Source code: S2.java package p1; import java.io.IOException; import javax.servlet.http.*; public class S2 extends HttpServlet { private static final long serialVersionUID = protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/html"); resp.setCharacterEncoding("UTF-8"); resp.getWriter().println(" Nice to see you, " + req.getParameter("input") + " "); }

24 (copying S2.class to classes)

25 Comments Changes in classes, web.xml require a restart of tomcat IDE can “talk” to the server –Debug a servlet as it runs –Download the necessary plugin(s) Automate the (development) deployment process This is the most primitive way to work with Tomcat –Frameworks will ease your life (Spring, Grails, …) Extending a servlet makes your life difficult –Testing, debugging, resusing –Delegate to a POJO Persistency: Files will not work –Serialization is evil –Files get corrupted –SQL simplifies data manipulation

26 Comments (cont.) Cross-browser incompatibility –Use a good Javascript library from day one –JQuery, Dojo, Prototype, … Distributed programming –Two processes: Server (Java), Client (Javascript) –No shared heap –IDs are used as pointers Additional techniques: CSS, Ajax, …

27 An excellent starting point “Developing a Spring Framework MVC application step-by-step” step-by-step