CS 112 Introduction to Programming

Size: px
Start display at page:

Download "CS 112 Introduction to Programming"

Transcription

1 CS 112 Introduction to Programming Web Programming: Backend (server side) Programming with Servlet, JSP Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone:

2 Outline q Admin and recap q Server-side web programming overview q Servlet programming q Java servlet page (JSP) 2

3 Admin q PS8 Part 2 (Bulldog tournament) Due Tuesday at 11:55 pm q Project checkpoint Due Thursday at 11:55 pm (Please use the CHECKPOINT template) q Project demo day 11:30 12:30 pm Apr. 30 at TEAL 3

4 Recap: HTML/CSS/Javascript q HTML: page content (model) Document object model (DOM) q CSS: display of content (view) q Javascript: interaction

5 Outline q Admin and recap q Server-side web programming overview 5

6 Web App--Server Side: Motivating Example (OPS2b) Madlib (template): One of the most <adjective> characters in fiction is named "Tarzan of the <plural-noun>." Tarzan was raised by a/an <noun> and lives in the <adjective> jungle in the heart of darkest <place>. He spends most of his time eating <plural-noun> and swinging from tree to <noun>. Whenever he gets angry, he beats on his chest and says, " <funny-noise>!" This is his war cry. Tarzan always dresses in <adjective> shorts made from the skin of a/an <noun> and his best friend is a/an <adjective> chimpanzee named Cheetah. He is supposed to be able to speak to elephants and <plural-noun>. In the movies, Tarzan is played by <person'sname>. 6

7 Web App--Server Side: Motivating Example Commandline Madlib (interaction): Welcome to the game of Mad Libs. I will ask you to provide several words and phrases to fill in a mad lib story. Your mad-lib has been created: The result will be displayed to you. One of the most silly characters in fiction is named Template file? tarzan.txt "Tarzan of the apples." Tarzan was raised by a/an frisbee and lives in the hungry jungle in the Please input an adjective: silly heart of darkest New Haven, CT. He spends most of his time Please input a plural noun: apples eating bees and swinging from tree to umbrella. Please input a noun: frisbee Whenever he gets angry, he beats on his chest and says, Please input an adjective: hungry " burp!" This is his war cry. Tarzan always dresses in Please input a place: New Haven, CT shiny shorts made from the skin of a/an jelly donut Please input a plural noun: bees and his best friend is a/an beautiful chimpanzee named Please input a noun: umbrella Cheetah. He is supposed to be able to speak to elephants and Please input a funny noise: burp spoons. In the movies, Tarzan is played by Keanu Reeves. Please input an adjective: shiny Please input a noun: jelly donut Please input an adjective: beautiful Please input a plural noun: spoons pseudo code? Please input a person's name: Keanu Reeves 7

8 Cmdline Madlib Pseudo Code Display welcome message Ask user to choose story template Process given template file foreach token in template file ask user input store token -> user input mapping Display story for each line for each word in line if word is token print user input else print word as it is Web presents a different medium to deliver app. The unit of interaction is Web page. Q: what Web pages?

9 Webpage-Based Programming q One way to think about a dynamic Web page is to think it as an object: it is constructed with given input parameters q A Web page may collect input from user and then create another Web page (object)--browsing input P1 input P2 input P3

10 Input to Create Each Page? Display welcome message P1 Ask user to choose story template file Input: None P2 Process given template file foreach token in template file ask user input store token -> user input mapping Input Chosen template Who collect? P3 Display story for each line for each word in line if word is token print user input else print word as it is Input User input for each token Chosen Template Who collect?

11 Server-side Page Creation Q: What is the mechanism in Web to collect user input?

12 HTML Form q Form

13 HTML Form Program to be invoked q A form gives instruction to the browser on inputs to be collected from user URL (program) to be invoked when sending to server <form action="/create" method="get > Step 1: Please pick an input story template: <div> <input type="text" name="file" size ="40" value="tarzan.txt"> </div> <input type="hidden" name="language" value="english > <div> <input type="submit" value="next" /> </div> Invisible on page. Used to pass internal data </form> How input is transported to server: get/post An input item to be collected

14 Form Input Type q <input type= text" name="q"> q <input type= checkbox name = myc /> q <input type= radio name = mypizzasize /> q <input type= range min= 0 max= 10 name = cheesiness /> q <select name="crust > <option value="thin">thin</option> <option value="thick">thick</option> <option value="cheese">cheese</option> </select>

15 Web Execution Flow: Client Side q After user clicks submit on a form, browser encodes each input in a format <name>=<value> requests page with URL: <form action>?<name>=<value>&<name>=<value>

16 Web Execution Flow: Server Side q Web server receives the request for the URL, finds the application for the URL, and passes the values of the parameters to the application q The application retrieves the parameters, generates a Web page, and sends the page back to the browser to display

17 Google App Engine q A platform to simplify the development and hosting of Web applications Simplified deployment Load balancing Automatic scaling Useful high-level services and APIs 17

18 Discussion: What GAE can do to allow simple, flexible server-side app programming? q Client browser After user clicks submit on a form, browser encodes each input in a format <name>=<value> requests page with URL: <form action>?<name>=<value>&<name>=<value> q Web server receives the request for the URL, finds the application for the URL, and passes the values of the parameters to the application. web.xml: User defines URL mapping the application retrieves the request parameters, generates a response Web page back to the browser to display

19 Discussion: What GAE can do to allow simple, flexible server-side app programming? q Client browser After user clicks submit on a form, browser encodes each input in a format <name>=<value> requests page with URL: Define Servlet <form action>?<name>=<value>&<name>=<value> class: conduct common processing steps; app overrides key step (doget/ dopost) to define q Web server receives the request for the URL, finds the application for the URL, and passes the values of the parameters to the application. app-specific behavior the application retrieves the request parameters, generates a response Web page back to the browser to display

20 Discussion: What GAE can do to allow simple, flexible server-side app programming? q Client browser After user clicks submit on a form, browser encodes each input in a format <name>=<value> requests page with URL: Define <form action>?<name>=<value>&<name>=<value> HttpServletRequest class to allow simple methods to retrieve parameter, e.g., getparameter( name ) q Web server receives the request for the URL, finds the application for the URL, and passes the values of the parameters to the application. the application retrieves the request parameters, generates a response Web page back to the browser to display

21 Discussion: What GAE can do to allow simple, flexible server-side app programming? q Client browser After user clicks submit on a form, browser encodes each input in a format <name>=<value> requests page with URL: Define <form action>?<name>=<value>&<name>=<value> HttpServletResponse class to allow simple methods to write response (not worry about sending across network), e.g., getwriter().println( <p>hello ) q Web server receives the request for the URL, finds the application for the URL, and passes the values of the parameters to the application. the application retrieves the request parameters, generates a response Web page back to the browser to display

22 Example Display welcome message Ask user to choose story template file Input: None index.html (see Note) Process given template file foreach token in template file ask user input store token -> user input mapping Display story for each line for each word in line if word is token print user input else print word as it is

23 web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi=" xmlns=" xmlns:web=" xsi:schemalocation=" version="2.5 > <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 23

24 Example Display welcome message Ask user to choose story template file Process given template file foreach token in template file ask user input store token -> user input mapping Input: Chosen template CreateMadlibServlet.java Display story for each line for each word in line if word is token print user input else print word as it is

25 web.xml q Allow a WebApp developer to declare the applications (servlets), and which servlet will serve which URL <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi=" xmlns=" xmlns:web=" xsi:schemalocation=" version="2.5"> <servlet> <servlet-name>createmadlibservlet</servlet-name> <servlet-class>madlibs.createmadlibservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>createmadlibservlet</servlet-name> <url-pattern>/create</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 25

26 Example Display welcome message Ask user to choose story template file Process given template file foreach token in template file ask user input store token -> user input mapping Display story for each line for each word in line if word is token print user input else print word as it is Input: User input for each token/template DisplayMadlibServlet.java

27 web.xml q Allow a WebApp developer to declare the applications (servlets), and which servlet will serve which URL <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi=" xmlns=" xmlns:web=" xsi:schemalocation=" version="2.5"> <servlet> <servlet-name>createmadlibservlet</servlet-name> <servlet-class>madlibs.createmadlibservlet</servlet-class> </servlet> <servlet> <servlet-name>displaymadlibservlet</servlet-name> <servlet-class>madlibs.displaymadlibservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>createmadlibservlet</servlet-name> <url-pattern>/create</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>displaymadlibservlet</servlet-name> <url-pattern>/display</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 27

28 Outline q Admin and recap q Server-side programming overview q Java Servlet q Java Servlet Page (jsp) 28

29 Motivation q Most used statement in CreateMadlibServlet.java? 29

30 Motivation q For many Web pages, most of the content will be static, and hence only a small portion will be generated dynamically q The Servlet architecture asks you to print the whole document (i.e., a large number of Java print and escape statements for printing the static part) q JSP goal: remove most of the print statements 30

31 Motivating Example q Generate an html page consisting of a list of 10 random numbers 31

32 Manual HTML <html> <body> <h2>my list</h2> <ul> <li>1: 9</li> <li>2: 3</li> <li>3: 5</li> <li>4: 1</li> <li>5: 7</li> <li>6: 4</li> <li>7: 0</li> <li>8: 2</li> <li>9: 8</li> <li>10: 9</li> </ul> </body> </html> 32

33 Servlet import java.util.random; public class NumListServlet extends HttpServlet { public void dopost(httpservletrequest req, HttpServletResponse resp) throws IOException { doget(req, resp); } public void doget(httpservletrequest req, HttpServletResponse resp) throws IOException { resp.setcontenttype("text/html"); resp.getwriter().println("<html>"); resp.getwriter().println("<body>"); resp.getwriter().println( <h2>my list</h2>"); resp.getwriter().println("<ul>"); Random rand = new Random(); for (int i = 1; i < 11; i ++) { resp.getwriter().print( <li>"); resp.getwriter().print( i + : + rand.nextint(10) ); resp.getwriter().println("</li>"); } resp.getwriter().println("</ul>"); } resp.getwriter().println("</body>"); resp.getwriter().println("</html>"); 33

34 JSP Motivation import java.util.random; public class NumListServlet extends HttpServlet { public void dopost(httpservletrequest req, HttpServletResponse resp) throws IOException { doget(req, resp); } public void doget(httpservletrequest req, HttpServletResponse resp) throws IOException { resp.setcontenttype("text/html"); resp.getwriter().println("<html>"); resp.getwriter().println("<body>"); resp.getwriter().println( <h2>my list</h2>"); resp.getwriter().println("<ul>"); Random rand = new Random(); for (int i = 1; i < 11; i ++) { resp.getwriter().print( <li>"); resp.getwriter().print(i + : + rand.nextint(10) ); resp.getwriter().println("</li>"); } resp.getwriter().println("</ul>"); } resp.getwriter().println("</body>"); resp.getwriter().println("</html>"); 34

35 JSP Motivation Directive page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { resp.getwriter().print( <li>"); %> </ul> </body> </html> } Called a JSP scriptlet, containing a fragment of java code resp.getwriter().print(i + : + rand.nextint(10) ); resp.getwriter().println("</li>"); Why it does not work? 35

36 Run test.jsp as /test 36

37 web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi=" xmlns=" xmlns:web=" xsi:schemalocation=" version="2.5"> <servlet> <servlet-name>createmadlibservlet</servlet-name> <servlet-class>madlibs.createmadlibservlet</servlet-class> </servlet> <servlet> <servlet-name>displaymadlibservlet</servlet-name> <servlet-class>madlibs.displaymadlibservlet</servlet-class> </servlet> <servlet> <servlet-name>testjsp</servlet-name> <jsp-file>test.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>testjsp</servlet-name> <url-pattern>/test</url-pattern> </servlet-mapping>... <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> 37

38 JSP Motivation Directive page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { response.getwriter().print( <li>"); %> </ul> </body> </html> } Called a JSP scriptlet, containing a fragment of java code response.getwriter().print(i + : + rand.nextint(10) ); response.getwriter().println("</li>"); implicit object See for implicit objects 38

39 Output 39

40 Problem Use implicit object out to print. out!= response.getwrite() page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { response.getwriter().print( <li>"); response.getwriter().print(i + : + rand.nextint(10) ); response.getwriter().println("</li>"); } %> </ul> </body> </html> 40

41 Fix page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { out.print( <li>"); out.print(i + : + rand.nextint(10) ); out.println("</li>"); } %> </ul> </body> </html> 41

42 Motivation page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { out.print( <li>"); out.print(i + : + rand.nextint(10) ); out.println("</li>"); } %> </ul> </body> </html> What if we do not want to use the print statement? 42

43 Attempt page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { %> <li> i : rand.nextint(10) </li> <% } %> </ul> </body> </html> Problem: i and rand.nextint(10) are not treated as Java exp. 43

44 JSP Expression page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random"%> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { %> <li> <%= i %>: <%= rand.nextint(10) %> </li> <% } %> </ul> </body> </html> <%= %> encloses JSP expression, whose value appears in the output to out. 44

45 Motivation: Reduce Embedded Scriptlets page contenttype="text/html;charset=utf-8" language="java %> page import= java.util.random %> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); for (int i = 1; i < 11; i ++) { %> <li> <%= i %>: <%= rand.nextint(10) %> </li> <% } %> </ul> </body> </html> 45

46 JSTL (JavaServer Pages Stanard Tag Library) q Objective: introduce JSP tags for common tasks such as conditional execution, loops, XML data access 46

47 Motivation: Reduce Embedded Scriptlets page contenttype="text/html;charset=utf-8" language="java %> taglib uri=" prefix="c" %> page import= java.util.random %> <html> <body> <h2>my list</h2> <ul> <% Random rand = new Random(); %> <c:foreach var="i" begin="1" end= 10"> <li> <c:out value="${i}"/> <%= rand.nextint(10) %></li> </c:foreach> </ul> </body> </html> 47

48 Java Servlet Page (JSP) q History Released in 1999 Similar to PHP but supports more sophisticated J2EE programming q Can be considered as a high-level abstraction of Java servlets q In real implementation, JSPs are translated to servlets at runtime 48

49 Exercise q Turn CreateMadlibServlet.java into createmadlib.jsp 49

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

Session 9. Introduction to Servlets. Lecture Objectives

Session 9. Introduction to Servlets. Lecture Objectives Session 9 Introduction to Servlets Lecture Objectives Understand the foundations for client/server Web interactions Understand the servlet life cycle 2 10/11/2018 1 Reading & Reference Reading Use the

More information

Session 8. Introduction to Servlets. Semester Project

Session 8. Introduction to Servlets. Semester Project Session 8 Introduction to Servlets 1 Semester Project Reverse engineer a version of the Oracle site You will be validating form fields with Ajax calls to a server You will use multiple formats for the

More information

Chapter 2 How to structure a web application with the MVC pattern

Chapter 2 How to structure a web application with the MVC pattern Chapter 2 How to structure a web application with the MVC pattern Murach's Java Servlets/JSP (3rd Ed.), C2 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge 1. Describe the Model 1 pattern.

More information

Introduction to Servlets. After which you will doget it

Introduction to Servlets. After which you will doget it Introduction to Servlets After which you will doget it Servlet technology A Java servlet is a Java program that extends the capabilities of a server. Although servlets can respond to any types of requests,

More information

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http? What are Servlets? Servlets1 Fatemeh Abbasinejad abbasine@cs.ucdavis.edu A program that runs on a web server acting as middle layer between requests coming from a web browser and databases or applications

More information

How to structure a web application with the MVC pattern

How to structure a web application with the MVC pattern Objectives Chapter 2 How to structure a web application with the MVC pattern Knowledge 1. Describe the Model 1 pattern. 2. Describe the Model 2 (MVC) pattern 3. Explain how the MVC pattern can improve

More information

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature INTRODUCTION TO SERVLETS AND WEB CONTAINERS Actions in Accord with All the Laws of Nature Web server vs web container Most commercial web applications use Apache proven architecture and free license. Tomcat

More information

Chapter 10 Servlets and Java Server Pages

Chapter 10 Servlets and Java Server Pages Chapter 10 Servlets and Java Server Pages 10.1 Overview of Servlets A servlet is a Java class designed to be run in the context of a special servlet container An instance of the servlet class is instantiated

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Java Server Pages (JSP) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information

UIMA Simple Server User Guide

UIMA Simple Server User Guide UIMA Simple Server User Guide Written and maintained by the Apache UIMA Development Community Version 2.3.1 Copyright 2006, 2011 The Apache Software Foundation License and Disclaimer. The ASF licenses

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411 1 Review:

More information

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Enterprise Edition Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Beans Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 2 Java Bean POJO class : private Attributes public

More information

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 데이타베이스시스템연구실 Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 Overview http://www.tutorialspoint.com/jsp/index.htm What is JavaServer Pages? JavaServer Pages (JSP) is a server-side programming

More information

Introduction to JSP and Servlets Training 5-days

Introduction to JSP and Servlets Training 5-days QWERTYUIOP{ Introduction to JSP and Servlets Training 5-days Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic

More information

Lab session Google Application Engine - GAE. Navid Nikaein

Lab session Google Application Engine - GAE. Navid Nikaein Lab session Google Application Engine - GAE Navid Nikaein Available projects Project Company contact Mobile Financial Services Innovation TIC Vasco Mendès Bluetooth low energy Application on Smart Phone

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System 15-415 Database Applications Recitation 6 Project 3: CMUQFlix CMUQ s Movies Recommendation System 1 Project Objective 1. Set up a front-end website with PostgreSQL as the back-end 2. Allow users to login,

More information

Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json

Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json A Servlet used as an API for data Let s say we want to write a Servlet

More information

Principles and Techniques of DBMS 6 JSP & Servlet

Principles and Techniques of DBMS 6 JSP & Servlet Principles and Techniques of DBMS 6 JSP & Servlet Haopeng Chen REliable, INtelligent and Scalable Systems Group (REINS) Shanghai Jiao Tong University Shanghai, China http://reins.se.sjtu.edu.cn/~chenhp

More information

LearningPatterns, Inc. Courseware Student Guide

LearningPatterns, Inc. Courseware Student Guide Fast Track to Servlets and JSP Developer's Workshop LearningPatterns, Inc. Courseware Student Guide This material is copyrighted by LearningPatterns Inc. This content shall not be reproduced, edited, or

More information

Unit 5 JSP (Java Server Pages)

Unit 5 JSP (Java Server Pages) Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. It focuses more on presentation logic

More information

Unit-4: Servlet Sessions:

Unit-4: Servlet Sessions: 4.1 What Is Session Tracking? Unit-4: Servlet Sessions: Session tracking is the capability of a server to maintain the current state of a single client s sequential requests. Session simply means a particular

More information

STRUTS 2 - HELLO WORLD EXAMPLE

STRUTS 2 - HELLO WORLD EXAMPLE STRUTS 2 - HELLO WORLD EXAMPLE http://www.tutorialspoint.com/struts_2/struts_examples.htm Copyright tutorialspoint.com As you learnt from the Struts 2 architecture, when you click on a hyperlink or submit

More information

JavaServer Pages (JSP)

JavaServer Pages (JSP) JavaServer Pages (JSP) The Context The Presentation Layer of a Web App the graphical (web) user interface frequent design changes usually, dynamically generated HTML pages Should we use servlets? No difficult

More information

welcome to BOILERCAMP HOW TO WEB DEV

welcome to BOILERCAMP HOW TO WEB DEV welcome to BOILERCAMP HOW TO WEB DEV Introduction / Project Overview The Plan Personal Website/Blog Schedule Introduction / Project Overview HTML / CSS Client-side JavaScript Lunch Node.js / Express.js

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2017 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2465 1 Review:

More information

Vendor: SUN. Exam Code: Exam Name: Sun Certified Web Component Developer for J2EE 5. Version: Demo

Vendor: SUN. Exam Code: Exam Name: Sun Certified Web Component Developer for J2EE 5. Version: Demo Vendor: SUN Exam Code: 310-083 Exam Name: Sun Certified Web Component Developer for J2EE 5 Version: Demo QUESTION NO: 1 You need to store a Java long primitive attribute, called customeroid, into the session

More information

3. The pool should be added now. You can start Weblogic server and see if there s any error message.

3. The pool should be added now. You can start Weblogic server and see if there s any error message. CS 342 Software Engineering Lab: Weblogic server (w/ database pools) setup, Servlet, XMLC warming up Professor: David Wolber (wolber@usfca.edu), TA: Samson Yingfeng Su (ysu@cs.usfca.edu) Setup Weblogic

More information

JavaServer Pages. What is JavaServer Pages?

JavaServer Pages. What is JavaServer Pages? JavaServer Pages SWE 642, Fall 2008 Nick Duan What is JavaServer Pages? JSP is a server-side scripting language in Java for constructing dynamic web pages based on Java Servlet, specifically it contains

More information

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres sessionx Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano A few more words about Common Gateway Interface 1 2 CGI So originally CGI purpose was to let communicate a

More information

Fast Track to Java EE

Fast Track to Java EE Java Enterprise Edition is a powerful platform for building web applications. This platform offers all the advantages of developing in Java plus a comprehensive suite of server-side technologies. This

More information

Advantage of JSP over Servlet

Advantage of JSP over Servlet JSP technology is used to create web application just like Servlet technology. It can be thought of as an extension to servlet because it provides more functionality than servlet such as expression language,

More information

First Simple Interactive JSP example

First Simple Interactive JSP example Let s look at our first simple interactive JSP example named hellojsp.jsp. In his Hello User example, the HTML page takes a user name from a HTML form and sends a request to a JSP page, and JSP page generates

More information

CE212 Web Application Programming Part 3

CE212 Web Application Programming Part 3 CE212 Web Application Programming Part 3 30/01/2018 CE212 Part 4 1 Servlets 1 A servlet is a Java program running in a server engine containing methods that respond to requests from browsers by generating

More information

Servlets and JSP (Java Server Pages)

Servlets and JSP (Java Server Pages) Servlets and JSP (Java Server Pages) XML HTTP CGI Web usability Last Week Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 2 Servlets Generic Java2EE API for invoking and connecting to mini-servers (lightweight,

More information

Servlet Basics. Agenda

Servlet Basics. Agenda Servlet Basics 1 Agenda The basic structure of servlets A simple servlet that generates plain text A servlet that generates HTML Servlets and packages Some utilities that help build HTML The servlet life

More information

STRUTS 2 - VALIDATIONS FRAMEWORK

STRUTS 2 - VALIDATIONS FRAMEWORK STRUTS 2 - VALIDATIONS FRAMEWORK http://www.tutorialspoint.com/struts_2/struts_validations.htm Copyright tutorialspoint.com Now we will look into how Struts's validation framework. At Struts's core, we

More information

UNIT -5. Java Server Page

UNIT -5. Java Server Page UNIT -5 Java Server Page INDEX Introduction Life cycle of JSP Relation of applet and servlet with JSP JSP Scripting Elements Difference between JSP and Servlet Simple JSP program List of Questions Few

More information

Connecting the RISC Client to non-javascriptinterfaces

Connecting the RISC Client to non-javascriptinterfaces Connecting the RISC Client to non-javascriptinterfaces Motivation In industry scenarios there is the necessity to connect the RISC client to client side subdevices or interfaces. Examples: serial / USB

More information

Building Web Applications With The Struts Framework

Building Web Applications With The Struts Framework Building Web Applications With The Struts Framework ApacheCon 2003 Session TU23 11/18 17:00-18:00 Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc. Slides: http://www.apache.org/~craigmcc/

More information

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session Kamnoetvidya Science Academy Object Oriented Programming using Java Ferdin Joe John Joseph Java Session Create the files as required in the below code and try using sessions in java servlets web.xml

More information

Ch04 JavaServer Pages (JSP)

Ch04 JavaServer Pages (JSP) Ch04 JavaServer Pages (JSP) Introduce concepts of JSP Web components Compare JSP with Servlets Discuss JSP syntax, EL (expression language) Discuss the integrations with JSP Discuss the Standard Tag Library,

More information

One application has servlet context(s).

One application has servlet context(s). FINALTERM EXAMINATION Spring 2010 CS506- Web Design and Development DSN stands for. Domain System Name Data Source Name Database System Name Database Simple Name One application has servlet context(s).

More information

Servlet Fudamentals. Celsina Bignoli

Servlet Fudamentals. Celsina Bignoli Servlet Fudamentals Celsina Bignoli bignolic@smccd.net What can you build with Servlets? Search Engines E-Commerce Applications Shopping Carts Product Catalogs Intranet Applications Groupware Applications:

More information

Session 10. Form Dataset. Lecture Objectives

Session 10. Form Dataset. Lecture Objectives Session 10 Form Dataset Lecture Objectives Understand the relationship between HTML form elements and parameters that are passed to the servlet, particularly the form dataset 2 10/1/2018 1 Example Form

More information

web.xml Deployment Descriptor Elements

web.xml Deployment Descriptor Elements APPENDIX A web.xml Deployment Descriptor s The following sections describe the deployment descriptor elements defined in the web.xml schema under the root element . With Java EE annotations, the

More information

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Advance Java. Configuring and Getting Servlet Init Parameters per servlet Advance Java Understanding Servlets What are Servlet Components? Web Application Architecture Two tier, three tier and N-tier Arch. Client and Server side Components and their relation Introduction to

More information

Accessing EJB in Web applications

Accessing EJB in Web applications Accessing EJB in Web applications 1. 2. 3. 4. Developing Web applications Accessing JDBC in Web applications To run this tutorial, as a minimum you will be required to have installed the following prerequisite

More information

Module 3 Web Component

Module 3 Web Component Module 3 Component Model Objectives Describe the role of web components in a Java EE application Define the HTTP request-response model Compare Java servlets and JSP components Describe the basic session

More information

Advanced Internet Technology Lab # 4 Servlets

Advanced Internet Technology Lab # 4 Servlets Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Advanced Internet Technology Lab # 4 Servlets Eng. Doaa Abu Jabal Advanced Internet Technology Lab # 4 Servlets Objective:

More information

Platform as a Service lecture 2

Platform as a Service lecture 2 Politecnico di Milano Platform as a Service lecture 2 Building an example application in Google App Engine Cloud patterns Elisabetta Di Nitto Developing an application for Google App Engine (GAE)! Install

More information

Component Based Software Engineering

Component Based Software Engineering Component Based Software Engineering Masato Suzuki School of Information Science Japan Advanced Institute of Science and Technology 1 Schedule Mar. 10 13:30-15:00 : 09. Introduction and basic concepts

More information

Web based Applications, Tomcat and Servlets - Lab 3 -

Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta The Basic Web Server CMPUT 391 Database Management

More information

Servlet and JSP Review

Servlet and JSP Review 2006 Marty Hall Servlet and JSP Review A Recap of the Basics 2 JSP, Servlet, Struts, JSF, AJAX, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com

More information

JSP CSCI 201 Principles of Software Development

JSP CSCI 201 Principles of Software Development JSP CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline JSP Program USC CSCI 201L JSP 3-Tier Architecture Client Server Web/Application Server Database USC

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

Getting started with Winstone. Minimal servlet container

Getting started with Winstone. Minimal servlet container Getting started with Winstone Minimal servlet container What is Winstone? Winstone is a small servlet container, consisting of a single JAR file. You can run Winstone on your computer using Java, and get

More information

112. Introduction to JSP

112. Introduction to JSP 112. Introduction to JSP Version 2.0.2 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform.

More information

CSE 154 LECTURE 8: FORMS

CSE 154 LECTURE 8: FORMS CSE 154 LECTURE 8: FORMS Web data most interesting web pages revolve around data examples: Google, IMDB, Digg, Facebook, YouTube, Rotten Tomatoes can take many formats: text, HTML, XML, multimedia many

More information

AIM. 10 September

AIM. 10 September AIM These two courses are aimed at introducing you to the World of Web Programming. These courses does NOT make you Master all the skills of a Web Programmer. You must learn and work MORE in this area

More information

CSC309: Introduction to Web Programming. Lecture 10

CSC309: Introduction to Web Programming. Lecture 10 CSC309: Introduction to Web Programming Lecture 10 Wael Aboulsaadat WebServer - WebApp Communication 2. Servlets Web Browser Get servlet/serv1? key1=val1&key2=val2 Web Server Servlet Engine WebApp1 serv1

More information

Structure of a webapplication

Structure of a webapplication Structure of a webapplication Catalogue structure: / The root of a web application. This directory holds things that are directly available to the client. HTML-files, JSP s, style sheets etc The root is

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Critters/Event-Driven Programming Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu Admin q Class project

More information

Example jsf-cdi-and-ejb can be browsed at

Example jsf-cdi-and-ejb can be browsed at JSF-CDI-EJB Example jsf-cdi-and-ejb can be browsed at https://github.com/apache/tomee/tree/master/examples/jsf-cdi-and-ejb The simple application contains a CDI managed bean CalculatorBean, which uses

More information

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar www.vuhelp.pk Solved MCQs with reference. inshallah you will found it 100% correct solution. Time: 120 min Marks:

More information

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 QUESTION NO: 1 To take advantage of the capabilities of modern browsers that use web standards, such as XHTML and CSS, your web application

More information

Contents at a Glance

Contents at a Glance Contents at a Glance 1 Java EE and Cloud Computing... 1 2 The Oracle Java Cloud.... 25 3 Build and Deploy with NetBeans.... 49 4 Servlets, Filters, and Listeners... 65 5 JavaServer Pages, JSTL, and Expression

More information

Specialized - Mastering JEE 7 Web Application Development

Specialized - Mastering JEE 7 Web Application Development Specialized - Mastering JEE 7 Web Application Development Code: Lengt h: URL: TT5100- JEE7 5 days View Online Mastering JEE 7 Web Application Development is a five-day hands-on JEE / Java EE training course

More information

Université du Québec à Montréal

Université du Québec à Montréal Laboratoire de Recherches sur les Technologies du Commerce Électronique arxiv:1803.05253v1 [cs.se] 14 Mar 2018 Université du Québec à Montréal How to Implement Dependencies in Server Pages of JEE Web Applications

More information

112-WL. Introduction to JSP with WebLogic

112-WL. Introduction to JSP with WebLogic Version 10.3.0 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform. The module begins

More information

Backend. (Very) Simple server examples

Backend. (Very) Simple server examples Backend (Very) Simple server examples Web server example Browser HTML form HTTP/GET Webserver / Servlet JDBC DB Student example sqlite>.schema CREATE TABLE students(id integer primary key asc,name varchar(30));

More information

SECTION II: JAVA SERVLETS

SECTION II: JAVA SERVLETS Chapter 7 SECTION II: JAVA SERVLETS Working With Servlets Working with Servlets is an important step in the process of application development and delivery through the Internet. A Servlet as explained

More information

Using Java servlets to generate dynamic WAP content

Using Java servlets to generate dynamic WAP content C H A P T E R 2 4 Using Java servlets to generate dynamic WAP content 24.1 Generating dynamic WAP content 380 24.2 The role of the servlet 381 24.3 Generating output to WAP clients 382 24.4 Invoking a

More information

JdbcResultSet.java. import java.sql.*;

JdbcResultSet.java. import java.sql.*; 1)Write a program to display the current contents of the tables in the database where table name is Registration and attributes are id,firstname,lastname,age. JdbcResultSet.java import java.sql.*; public

More information

Experiment No: Group B_2

Experiment No: Group B_2 Experiment No: Group B_2 R (2) N (5) Oral (3) Total (10) Dated Sign Problem Definition: A Web application for Concurrent implementation of ODD-EVEN SORT is to be designed using Real time Object Oriented

More information

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Fast Track to Java EE 5 with Servlets, JSP & JDBC Duration: 5 days Description Java Enterprise Edition (Java EE 5) is a powerful platform for building web applications. The Java EE platform offers all the advantages of developing in Java plus a comprehensive

More information

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation Welcome To PhillyJUG 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation Web Development With The Struts API Tom Janofsky Outline Background

More information

Admin. CS 112 Introduction to Programming. Admin. Admin. Recap. Recap: Polymorphism and Arrays. the Google doc to record the teaming

Admin. CS 112 Introduction to Programming. Admin. Admin. Recap. Recap: Polymorphism and Arrays. the Google doc to record the teaming Admin CS 112 Introduction to Programming Critters/Event-Driven Programming Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu q Class project

More information

CS 268 Lab 6 Eclipse Test Server and JSPs

CS 268 Lab 6 Eclipse Test Server and JSPs CS 268 Lab 6 Eclipse Test Server and JSPs Setting up Eclipse The first thing you will do is to setup the Eclipse Web Server environment for testing. This will create a local web server running on your

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Conditional Statements Boolean Expressions and Methods Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Conditional Statements Boolean Expressions and Methods Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu

More information

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. Preface p. xiii Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. 11 Creating the Deployment Descriptor p. 14 Deploying Servlets

More information

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: Objectives/Outline Objectives Outline Understand the role of Learn how to use in your web applications Rich User Experience

More information

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4 CMPUT 391 Database Management Systems The Basic Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems

More information

Introduction. This course Software Architecture with Java will discuss the following topics:

Introduction. This course Software Architecture with Java will discuss the following topics: Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Integrate JPEGCAM with WaveMaker

Integrate JPEGCAM with WaveMaker Integrate JPEGCAM with WaveMaker 1.Start a new project on wavemaker or use your current project 2.On Main page or desired page add a panel widget and put name panelholder 3.Create a wm.variable called

More information

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum JEE application servers at version 5 or later include the required JSF libraries so that applications need not configure them in the Web app. Instead of using JSPs for the view, you can use an alternative

More information

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP:

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP: http://www.tutorialspoint.com/jsp/jsp_syntax.htm JSP - SYNTAX Copyright tutorialspoint.com This tutorial will give basic idea on simple syntax ie. elements involved with JSP development: The Scriptlet:

More information

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming INTRODUCTION JAVA SERVLET Server-side Programming INTRODUCTION 1 AGENDA Introduction Java Servlet Web/Application Server Servlet Life Cycle Web Application Life Cycle Servlet API Writing Servlet Program Summary 2 INTRODUCTION

More information

(Worth 50% of overall Project 1 grade)

(Worth 50% of overall Project 1 grade) 第 1 页共 8 页 2011/11/8 22:18 (Worth 50% of overall Project 1 grade) You will do Part 3 (the final part) of Project 1 with the same team as for Parts 1 and 2. If your team partner dropped the class and you

More information

JAVA SERVLET. Server-side Programming PROGRAMMING

JAVA SERVLET. Server-side Programming PROGRAMMING JAVA SERVLET Server-side Programming PROGRAMMING 1 AGENDA Passing Parameters Session Management Cookie Hidden Form URL Rewriting HttpSession 2 HTML FORMS Form data consists of name, value pairs Values

More information

Fall Semester (081) Module7: AJAX

Fall Semester (081) Module7: AJAX INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: AJAX Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals alfy@kfupm.edu.sa

More information

Enterprise Development

Enterprise Development Enterprise Development with What needs to be done to run JEE like applications inside Karaf? @anierbeck - Karaf PMC, Apache Member - OPS4j Pax Web Project Lead - Senior IT Consultant @codecentric - co-author

More information

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003 Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Handout 31 Web Design & Development

Handout 31 Web Design & Development Lecture 31 Session Tracking We have discussed the importance of session tracking in the previous handout. Now, we ll discover the basic techniques used for session tracking. Cookies are one of these techniques

More information

Module 4: SERVLET and JSP

Module 4: SERVLET and JSP 1.What Is a Servlet? Module 4: SERVLET and JSP A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the Hyper

More information

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA Setting up Java Development Kit This step involves downloading an implementation of the Java Software Development

More information

11.1 Introduction to Servlets

11.1 Introduction to Servlets 11.1 Introduction to Servlets - A servlet is a Java object that responds to HTTP requests and is executed on a Web server - Servlets are managed by the servlet container, or servlet engine - Servlets are

More information

SERVLETS INTERVIEW QUESTIONS

SERVLETS INTERVIEW QUESTIONS SERVLETS INTERVIEW QUESTIONS http://www.tutorialspoint.com/servlets/servlets_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Servlets Interview Questions have been designed especially

More information