In Class Assg 3 - Solution

Slides:



Advertisements
Similar presentations
Apache Tomcat as a container for Servlets and JSP
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
COMP 321 Week 8. Overview MVC Example Servlet Lifecycle Servlet Mechanics MVC Lab 5-2 Solution Lab 8-1 Introduction.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
Servlets and JDBC. Servlets A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password:
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.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
1 Web Applications – The Basics. 2 Unzipped Tomcat Folder.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password:
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
A Servlet’s Job Read explicit data sent by client (form data) Read implicit data sent by client (request headers) Generate the results Send the explicit.
CSCI 6962: Server-side Design and Programming History and Background.
Hints for HW#8. HW#6 Architecture Result of Query GOOG Browser with web page PHP Script client Apache web server finance.yahoo.com Send query with arguments.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Chapter 91© copyright Janson Industries 2011 Java Design Concepts ■ JSP’s ■ MVC MVC ■ Beans Beans ■ JSP Tags JSP Tags.
Session Beans Overview EJB container Remote Invocation Represent client's access to app Local / Remote speed / flexibility trade-off when to choose local.
Chapter 111© copyright Janson Industries 2011 Custom Tags ▮ Tag Handlers ▮ XML ▮ Tag Libraries ▮ Web Deployment Descriptor.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
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.
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.
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
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.
Java Servlets. Servlets When we run small Java programs within a browser these are referred to as Applets... And when we run small Java programs within.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
The Simplest Possible Tool - Iteration 1 Vancouver Bootcamp Mike Osterman
Servlet Communication Other Servlets, HTML pages, objects shared among servlets on same server Servlets on another server with HTTP request of the other.
이경화 Ch13. 웹 프로그래밍 설계 및 실습 MVC2 Member.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Top right corner for field-mark, customer or partner logotypes. See Best practice for example. Slide title 40 pt Slide subtitle 24 pt Text 24 pt Bullets.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
Li Tak Sing COMPS311F. A web page that counts the number of times that you have visited the page. You can try the page at:
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
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.
Introduction To HTML Dr. Magdi AMER. HTML elements.
ClaRA web services V. Gyurjyan Clas12 Software Meeting
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,
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
OOSD Using Java CBTS Framework. 11/2/04CBTS2 Servlet  A servlet is a Java program that can extends Web server’s functionality.  Servlets interact with.
Introduction to Servlets
Principles of Software Development
Handling Errors in Web Applications
Servlet Fudamentals.
Net-centric Computing
Session Tracking in Servlets
HTTP Servlet Overview Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might.
V. Gyurjyan Clas12 Software Meeting
SERVLETS AND JDBC.
In Class Assg 4 - Solution
Jagdish Gangolly State University of New York at Albany
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Servlets & JSP.
In Class Assg 2 - solution
© copyright Janson Industries 2011
© copyright Janson Industries 2011
© 2014, Mike Murach & Associates, Inc.
COP 4610L: Applications in the Enterprise Spring 2005
Servlets.
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
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.
Presentation transcript:

In Class Assg 3 - Solution Sale.html should invoke SaleServlet Create SaleServlet to: Echo back the data from the Sale Web Page Sale Servlet User Sale.html HTML (response) With Sale info Chapter 8 © copyright Janson Industries 2011

© copyright Janson Industries 2011 import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class SaleServlet extends HttpServlet { private static final long serialVersionUID = 1L; public SaleServlet() { super(); } protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); try { PrintWriter out = new PrintWriter(resp.getOutputStream()); String CustName = req.getParameter("CustName"); String ItemName = req.getParameter("ItemName"); String Qty = req.getParameter("Qty"); String Price = req.getParameter("Price"); out.println("<HTML>"); Chapter 8 © copyright Janson Industries 2011

In Class Assg 3 - Solution out.println("<HEAD><Title>Servlet Response</Title></HEAD>"); out.println("<BODY>"); out.println("The customer name is: " + CustName + "<BR>"); out.println("The item name is: " + ItemName + "<BR>"); out.println("The quantity is: " + Qty + "<BR>"); out.println("The price is: " + Price + "<BR>"); out.println("</BODY>"); out.println("</HTML>"); out.close(); } catch (Exception e) { System.out.println("Sample Servlet failed: "); e.printStackTrace(); } Don’t forget to change Sale.html to invoke SaleServlet Chapter 8 © copyright Janson Industries 2011