&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,

Size: px
Start display at page:

Download "&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,"

Transcription

1 ! "# # $!

2 " &' ()!"#$$&$'(!!! ($) * + #!,)& - #-& +"- #!(-& #& #$.//0& -#-!& #-$$!& 1+#& 2-2" (3" 3 * * +, - -!

3 #.// HttpServlet $ Servlet 2 $"!4)$5 #& 5 5 6! 0 -.// # $

4 $ 7 74) :( (9 6 " ) - 9 -)" )5 -;!6 #$&& '&! 7 #& < = $!>? : #"$+-?& -:?! 9 $ ( 7 5!,?:!)* (

5 *4! + *4869 navegador HTTP request HTTP request HTTP server servlet container static content servlet,

6 & 7 init() service() destroy() >A! :! $ 9,, :; < 2B! 4) +))2B9 4) +))! C+;B+D$8 8-9! B 9! -,

7 ' (./: 29! B 9! B 29! B!+;B+! <SERVLET> CODE=ServletName CODEBASE= <PARAM NAME=param1 VALUE=value1> If you see this text, your web server does not support the SERVLET tag. </SERVLET>, - 0? ' < = (./: 2>, (./: ),!

8 ( >.// )>#&doget() dopost() HttpServlet " (service()$ 5( + 8.' ,89,# >.// )EHttpRequest! < ) 2 &! 9, < getparametervalues(string name) getremotehost() getservername(),$

9 ) >.//869 )EHttpResponse!< (= + & 7! 9 5 < setcontentlength(int length) setcontenttype(string name) getwriter(), < > init() destroy()$ doget() init() )EServletConfig 8 F 8 F = )$"$!?: destroy() 1! F 9! F = ),(

10 :;,89 + 4) doget().". 4) doget() ) 8< HttpServletRequest HttpServletResponse,+ & public class HelloServlet extends javax.servlet.http.httpservlet { public void doget( javax.servlet.http.httpservletrequest req, javax.servlet.http.httpservletresponse res ) throws java.io.ioexception{ res.setcontenttype("text/html"); java.io.printwriter out = res.getwriter(); out.println ("<html>"); out.println ("<BODY>"); out.println ("Hello World!"); out.println ("</BODY>"); out.println ("</HTML>");

11 / ( HelloWorld 8 HttpServletRequest 9 BdoPost()< <HTML> <BODY> <FORM METHOD=POST ACTION=" Please enter your name. Thank you. <INPUT TYPE=TEXT NAME="firstName"> <P> <INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML>, / import java.io.*; import javax.servlet.http.*; public class NewHelloServlet extends HttpServlet { public void dopost( HttpServletRequest req, HttpServletResponse res ) throws IOException{ res.setcontenttype("text/html"); PrintWriter out = res.getwriter(); out.println ("<html>"); out.println ("<BODY>"); String name = req.getparameter("firstname"); if (name.length() > 0) out.println ("Hello: " + Name + " How are you?"); else out.println ("Hello Anonymous!"); out.println ("</BODY></HTML>");

12 " > 9 A < + 6!# &$ = '@ 6!$ 4) 6!!)" 6! setstatus() +"< public void dopost( HttpServletRequest req, HttpServletResponse res) throws IOException{ res.setstatus(sc_moved_temporarily); // send response body if necessary!

13 # ' HttpServletResponse -9 "< Content-Type setcontenttype() ) setheader() 1 )(! 9! B public void dopost( HttpServletRequest req, HttpServletResponse res) throws IOException{ res.setcontenttype("text/html"); // # :; = ) 9!getOutputStream() 5getWriter() ) 9! * setcontenttype() + image/gif : + = $

14 $ A 2'! ' # & ' ) A Cookie() '$ addcookie() HttpServletResponse '! getcookies() )E' Cookie mycookie = new Cookie("Me", "123"); res.addcookie(mycookie); Cookie[] cookies = req.getcookies(); if (cookies!= null) { String readvalue; for (int I = 0; I < cookies.length; I++) readvalue = cookies[i].getvalue();... (

15 3". 5 G= 8 HelloServlet ; 9 8 =! ; 9 doget() dopost() =! + *+, : 6 HB1I +J J )JJ )J"E J @)J"J4+?'1*J 4) ( #4& F - ) >4)! " K(<JJ(<LMLMJ "('D #HB1I +J@)J J "(& : K(<JJ(<LMLMJ'J "('D HB1I +J@)J'J "(

16 &?*-! ) 4) -() ) - A 4) "-/# 0 & & " 12 #B$!$ $& - #/& 2 4) ( 4 6, >@?*- : 6 ( #H& & 9! -$- $ 12 /& 3 2 / ) HJ4+?'1*JJ - < $/$ 0 HJ4+?'1*J )J 45 )2 # 2 /2 ( &

17 ' -.+! /0 1+2 <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " <web-app> <servlet> <servlet-name>hi</servlet-name> <servlet-class>helloservlet</servlet-class> </servlet> <servlet> <servlet-name>login</servlet-name> <servlet-class>loginservlet</servlet-class> <init-param> <param-name>admin </param-name> </init-param> </servlet> </web-app> <!! import javax.servlet.*; import java.io.ioexception; public class ReserveConfigServlet implements Servlet { ServletConfig servletconfig; public void init(servletconfig config) throws ServletException { servletconfig = config; public void destroy() { public void service(servletrequest req, ServletResponse res) throws ServletException, IOException { public String getservletinfo() { return null; public ServletConfig getservletconfig() { return servletconfig;!

18 ( <!! public void service(servletrequest req, ServletResponse res) throws ServletException, IOException { ServletContext servletcontext = servletconfig.getservletcontext(); Enumeration attributes = servletcontext.getattributenames(); while (attributes.hasmoreelements()) { String attribute = (String) attributes.nextelement(); System.out.println("Attribute name : " + attribute); System.out.println("Attribute value : " + servletcontext.getattribute(attribute)); System.out.println("Major version: " + servletcontext.getmajorversion()); System.out.println("Minor version: " + servletcontext.getminorversion()); System.out.println("Server info: " + servletcontext.getserverinfo()); # 345!, import javax.servlet.*; import java.io.*; public class SingleThreadedServlet extends GenericServlet implements SingleThreadModel { public void service(servletrequest request, ServletResponse response) throws ServletException, IOException { int counter = 0; // get saved value try { BufferedReader reader = new BufferedReader( new FileReader("counter.txt")); counter = Integer.parseInt( reader.readline() ); reader.close(); catch (Exception e) { $

19 ) 345!,/"2 // increment counter counter++; // save new value try { BufferedWriter writer = new BufferedWriter( new FileWriter("counter.txt")); writer.write(integer.tostring(counter)); writer.close(); catch (Exception e) { try { PrintWriter out = response.getwriter(); out.println("you are visitor number " + counter); catch (Exception e) { * NO! 9 )EHttpServletRequest HttpServletRespost +" 5!< 5 2 web.xml!<filter>!<filer-mapping> 9 (

20 " 2( import java.io.ioexception; import javax.servlet.filter; import javax.servlet.filterchain; import javax.servlet.filterconfig; import javax.servlet.servletexception; import javax.servlet.servletrequest; import javax.servlet.servletresponse; public class BasicFilter implements Filter { private FilterConfig filterconfig; public void init(filterconfig filterconfig) throws ServletException { System.out.println("Filter initialized"); this.filterconfig = filterconfig public void destroy() { System.out.println("Filter destroyed"); this.filterconfig = null; public void dofilter(servletrequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { System.out.println("doFilter"); chain.dofilter(req, res); + -.+! <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " <web-app> <!-- Define servlet-mapped and path-mapped filters --> <filter> <filter-name> Basic Filter </filter-name> <filter-class> BasicFilter </filter-class> </filter>!

21 " -.+! /"2 <!-- Define filter mappings for the defined filters --> <filter-mapping> <filter-name> Basic Filter </filter-name> <servlet-name> FilteredServlet </servlet-name> </filter-mapping> <listener> <listener-class> SessionLifeCycleEventDemo </listener-class> </listener> <servlet> <servlet-name> FilteredServlet </servlet-name> <servlet-class> FilteredServlet </servlet-class> </servlet> </web-app>!, public class ResponseFilter implements Filter { private FilterConfig filterconfig = null; public void destroy() { System.out.println("Filter destroyed"); this.filterconfig = null; public void dofilter(servletrequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("doFilter"); PrintWriter out = response.getwriter(); // this is added to the beginning of the PrintWriter out.println("<html>"); out.println("<body>"); out.println("<center>"); out.println("page header"); out.println("<hr>"); chain.dofilter(request, response); // this is added to the end of the PrintWriter out.println("<hr>"); out.println("page footer"); out.println("<center>"); out.println("</body>"); out.println("</html>"); public void init(filterconfig filterconfig) throws ServletException { System.out.println("Filter initialized"); this.filterconfig = filterconfig;!

22 "" / 2) < 2 ) 5 ' 7 G$< B! 9 -!3 3 <!! + 6!! / 1doGet()$-)!" E" 3" 3IOException ServletException 1"#"$ InterruptedException& < F )! ">!! - )UnavailableException " 3 ("!!

23 "# - *< Servlet# P& init(servletconf config) Q ( service(servletrequest req, ServletResponse resp)q 5 ServletConfig# P& getinitparameter(string name) Q 8 ServletContext# P& getserverinfo() Q 9 log() Q!E ServletRequest ServletResponse!# - *< GenericServlet# P& ServletConfig ))' service() getservletinfo() ServletInputStream# P& readline(byte[] b, int off, int len) Qoff$ Alen \n; = -1#eostream& ServletOuputStream# P& print(int i) Q print(string s) Q!$

24 "$ - *< HttpServlet# P&.M +genericservlet ))' doget() dopost() service(httpservletrequest req, HttpServletResponse res) Q ' #! 2& HttpServletRequest# P& +ServletRequest getheader(string name) Q ( getremoteuser() Q 55 HttpServletResponse# P& HttpUtils# P&!

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

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

JSP. Common patterns

JSP. Common patterns JSP Common patterns Common JSP patterns Page-centric (client-server) CLIENT JSP or Servlet CLIENT Enterprise JavaBeans SERVER DB Common JSP patterns Page-centric 1 (client-server) Page View request response

More information

ServletConfig Interface

ServletConfig Interface ServletConfig Interface Author : Rajat Categories : Advance Java An object of ServletConfig is created by the web container for each servlet. This object can be used to get configuration information from

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

Advanced Web Technology

Advanced Web Technology Berne University of Applied Sciences Dr. E. Benoist Winter Term 2005-2006 Presentation 1 Presentation of the Course Part Java and the Web Servlet JSP and JSP Deployment The Model View Controler (Java Server

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Java Servlets Adv. Web Technologies 1) Servlets (introduction) Emmanuel Benoist Fall Term 2016-17 Introduction HttpServlets Class HttpServletResponse HttpServletRequest Lifecycle Methods Session Handling

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

Java Servlets. Preparing your System

Java Servlets. Preparing your System Java Servlets Preparing to develop servlets Writing and running an Hello World servlet Servlet Life Cycle Methods The Servlet API Loading and Testing Servlets Preparing your System Locate the file jakarta-tomcat-3.3a.zip

More information

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle Introduction Now that the concept of servlet is in place, let s move one step further and understand the basic classes and interfaces that java provides to deal with servlets. Java provides a servlet Application

More information

文字エンコーディングフィルタ 1. 更新履歴 2003/07/07 新規作成(第 0.1 版) 版 数 第 0.1 版 ページ番号 1

文字エンコーディングフィルタ 1. 更新履歴 2003/07/07 新規作成(第 0.1 版) 版 数 第 0.1 版 ページ番号 1 1. 2003/07/07 ( 0.1 ) 0.1 1 2. 2.1. 2.1.1. ( ) Java Servlet API2.3 (1) API (javax.servlet.filter ) (2) URL 2.1.2. ( ) ( ) OS OS Windows MS932 Linux EUC_JP 0.1 2 2.1.3. 2.1.2 Web ( ) ( ) Web (Java Servlet

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

Java Technologies Web Filters

Java Technologies Web Filters Java Technologies Web Filters The Context Upon receipt of a request, various processings may be needed: Is the user authenticated? Is there a valid session in progress? Is the IP trusted, is the user's

More information

Chapter 17. Web-Application Development

Chapter 17. Web-Application Development Chapter 17. Web-Application Development Table of Contents Objectives... 1 17.1 Introduction... 1 17.2 Examples of Web applications... 2 17.2.1 Blogs... 2 17.2.2 Wikis... 2 17.2.3 Sakai... 3 17.2.4 Digital

More information

AJP. CHAPTER 5: SERVLET -20 marks

AJP. CHAPTER 5: SERVLET -20 marks 1) Draw and explain the life cycle of servlet. (Explanation 3 Marks, Diagram -1 Marks) AJP CHAPTER 5: SERVLET -20 marks Ans : Three methods are central to the life cycle of a servlet. These are init( ),

More information

UNIT-V. Web Servers: Tomcat Server Installation:

UNIT-V. Web Servers: Tomcat Server Installation: UNIT-V Web Servers: The Web server is meant for keeping Websites. It Stores and transmits web documents (files). It uses the HTTP protocol to connect to other computers and distribute information. Example:

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

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Overview Dynamic web content genera2on (thus far) CGI Web server modules Server- side scrip2ng e.g. PHP, ASP, JSP Custom web server Java

More information

Introduction to Web applications with Java Technology 3- Servlets

Introduction to Web applications with Java Technology 3- Servlets Introduction to Web applications with Java Technology 3- Servlets Juan M. Gimeno, Josep M. Ribó January, 2008 Contents Introduction to web applications with Java technology 1. Introduction. 2. HTTP protocol

More information

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web UNIT - 4 Servlet 4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web browser and request the servlet, example

More information

Servlets Basic Operations

Servlets Basic Operations Servlets Basic Operations Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Preparing to

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

Lecture Notes On J2EE

Lecture Notes On J2EE BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On J2EE Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. INTRODUCTION TO SERVLET Java Servlets are server side Java programs that require

More information

SERVLET AND JSP FILTERS

SERVLET AND JSP FILTERS SERVLET AND JSP FILTERS FILTERS OVERVIEW Filter basics Accessing the servlet context Using initialization parameters Blocking responses Modifying responses FILTERS: OVERVIEW Associated with any number

More information

Servlet. Web Server. Servlets are modules of Java code that run in web server. Internet Explorer. Servlet. Fire Fox. Servlet.

Servlet. Web Server. Servlets are modules of Java code that run in web server. Internet Explorer. Servlet. Fire Fox. Servlet. Servlet OOS Lab Servlet OOS Servlets are modules of Java code that run in web server. Internet Explorer Web Server Fire Fox Servlet Servlet Servlet Java Application 2 Servlet - Example OOS import java.io.*;

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

Topics. Advanced Java Programming. Quick HTTP refresher. Quick HTTP refresher. Web server can return:

Topics. Advanced Java Programming. Quick HTTP refresher. Quick HTTP refresher. Web server can return: Advanced Java Programming Servlets Chris Wong chw@it.uts.edu.au Orginal notes by Dr Wayne Brookes and Threading Copyright UTS 2008 Servlets Servlets-1 Copyright UTS 2008 Servlets Servlets-2 Quick HTTP

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

Servlets Pearson Education, Inc. All rights reserved.

Servlets Pearson Education, Inc. All rights reserved. 1 26 Servlets 2 A fair request should be followed by the deed in silence. Dante Alighieri The longest part of the journey is said to be the passing of the gate. Marcus Terentius Varro If nominated, I will

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

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

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

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets ID2212 Network Programming with Java Lecture 10 Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets Leif Lindbäck, Vladimir Vlassov KTH/ICT/SCS HT 2015

More information

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web Introduction to Java Servlets James Baldo Jr. SWE 432 Design and Implementation of Software for the Web Web Applications A web application uses enabling technologies to 1. make web site contents dynamic

More information

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

JAVA SERVLET. Server-side Programming ADVANCED FEATURES JAVA SERVLET Server-side Programming ADVANCED FEATURES 1 AGENDA RequestDispacher SendRedirect ServletConfig ServletContext ServletFilter SingleThreadedModel Events and Listeners Servlets & Database 2 REQUESTDISPATCHER

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

HTTP and the Dynamic Web

HTTP and the Dynamic Web HTTP and the Dynamic Web How does the Web work? The canonical example in your Web browser Click here here is a Uniform Resource Locator (URL) http://www-cse.ucsd.edu It names the location of an object

More information

Servlets. An extension of a web server runs inside a servlet container

Servlets. An extension of a web server runs inside a servlet container Servlets What is a servlet? An extension of a web server runs inside a servlet container A Java class derived from the HttpServlet class A controller in webapplications captures requests can forward requests

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

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

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently.

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

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22. Answers 1. What is the super interface to all the JDBC Drivers, specify their fully qualified name? a. Java.sql.Driver i. JDBC-ODBC Driver ii. Java-Native API Driver iii. All Java Net Driver iv. Java Native

More information

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

How does the Web work? HTTP and the Dynamic Web. Naming and URLs. In Action. HTTP in a Nutshell. Protocols. The canonical example in your Web browser

How does the Web work? HTTP and the Dynamic Web. Naming and URLs. In Action. HTTP in a Nutshell. Protocols. The canonical example in your Web browser How does the Web work? The canonical example in your Web browser and the Dynamic Web Click here here is a Uniform Resource Locator (URL) http://www-cse.ucsd.edu It names the location of an object on a

More information

The Servlet Life Cycle

The Servlet Life Cycle The Servlet Life Cycle What is a servlet? Servlet is a server side component which receives a request from a client, processes the request and sends a content based response back to the client. The Servlet

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

Develop an Enterprise Java Bean for Banking Operations

Develop an Enterprise Java Bean for Banking Operations Develop an Enterprise Java Bean for Banking Operations Aim: Develop a Banking application using EJB3.0 Software and Resources: Software or Resource Version Required NetBeans IDE 6.7, Java version Java

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

JAVA. Web applications Servlets, JSP

JAVA. Web applications Servlets, JSP JAVA Web applications Servlets, JSP Overview most of current web pages are dynamic technologies and laguages CGI, PHP, ASP,... now we do not talk about client side dynamism (AJAX,..) core Java-based technologies

More information

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype=text/html; charset=windows-31j import=java.util.calendar %> A JSP A.1 JSP Servlet Java HTML JSP HTML Java ( HTML JSP ) JSP Servlet Servlet HTML JSP MyDate.jsp

More information

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON-

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON- Ordering Information: Advanced Java 2 Platform How to Program View the complete Table of Contents Read the Preface Download the Code Examples To view all the Deitel products and services available, visit

More information

JAVA SERVLETS INTRODUCTION SERVLETS SHRI GURU RAM RAI INSTITUTE OF TECHNOLOGY & SCIENCE, DEHRADUN

JAVA SERVLETS INTRODUCTION SERVLETS SHRI GURU RAM RAI INSTITUTE OF TECHNOLOGY & SCIENCE, DEHRADUN JAVA SERVLETS INTRODUCTION Java servlets are programs that run on web server. Java applets are programs that are embedded into the web pages. When browser loads the web page the applets byte code is downloaded

More information

********************************************************************

******************************************************************** ******************************************************************** www.techfaq360.com SCWCD Mock Questions : Servlet ******************************************************************** Question No :1

More information

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY UNIT IV SERVLETS 1. What is Servlets? a. Servlets are server side components that provide a powerful mechanism

More information

Unit 4 - Servlet. Servlet. Advantage of Servlet

Unit 4 - Servlet. Servlet. Advantage of Servlet Servlet Servlet technology is used to create web application, resides at server side and generates dynamic web page. Before Servlet, CGI (Common Gateway Interface) was popular as a server-side programming

More information

Introdução a Servlets

Introdução a Servlets Introdução a Servlets Sumário 7.1.1.Introdução 7.1.2.Servlet Overview and Architecture 7.1.2.1 Interface Servlet and the Servlet Life Cycle 7.1.2.2 HttpServlet Class 7.1.2.3 HttpServletRequest Interface

More information

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC)

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC) Session 8 JavaBeans 1 Reading Reading & Reference Head First Chapter 3 (MVC) Reference JavaBeans Tutorialdocs.oracle.com/javase/tutorial/javabeans/ 2 2/27/2013 1 Lecture Objectives Understand how the Model/View/Controller

More information

CIS 3952 [Part 2] Java Servlets and JSP tutorial

CIS 3952 [Part 2] Java Servlets and JSP tutorial Java Servlets Example 1 (Plain Servlet) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet;

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

Servlet And JSP. Mr. Nilesh Vishwasrao Patil, Government Polytechnic, Ahmednagar. Mr. Nilesh Vishwasrao Patil

Servlet And JSP. Mr. Nilesh Vishwasrao Patil, Government Polytechnic, Ahmednagar. Mr. Nilesh Vishwasrao Patil Servlet And JSP, Government Polytechnic, Ahmednagar Servlet : Introduction Specific Objectives: To write web based applications using servlets, JSP and Java Beans. To write servlet for cookies and session

More information

WEB APPLICATION ESSENTIALS

WEB APPLICATION ESSENTIALS Module 2 WEB APPLICATION ESSENTIALS Objectives > After completing this lesson, you should be able to: Describe Java servlet technology Describe JavaServer Pages technology Define a Model-View-Controller

More information

Questions and Answers

Questions and Answers Q.1) Servlet mapping defines A. An association between a URL pattern and a servlet B. An association between a URL pattern and a request page C. An association between a URL pattern and a response page

More information

Java Servlets Basic Concepts and Programming

Java Servlets Basic Concepts and Programming Basic Concepts and Programming Giuseppe Della Penna Università degli Studi di L Aquila dellapenna@univaq.it http://www.di.univaq.it/gdellape This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike

More information

Chapter 29 Servlets: Bonus for Java Developers 1041

Chapter 29 Servlets: Bonus for Java Developers 1041 Chapter 29 Servlets: Bonus for Java Developers 1041 29 Servlets: Bonus for Java Developers Method Description void init( ServletConfig config ) This method is automatically called once during a servlet

More information

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M EXPLANATION - 1.B HTML FORM CREATION - 2 M SERVLET CODE IN POST METHOD IMPORT STATEMENTS - CLASS NAME AND METHOD (POST) -

More information

Java4570: Session Tracking using Cookies *

Java4570: Session Tracking using Cookies * OpenStax-CNX module: m48571 1 Java4570: Session Tracking using Cookies * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract

More information

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR Installing a Web Server 1. Install a sample web server, which supports Servlets/JSPs. A light weight web server is Apache Tomcat server. You can get the server from http://tomcat.apache.org/ 2. Follow

More information

Web Technology Programming Web Applications with Servlets

Web Technology Programming Web Applications with Servlets Programming Web Applications with Servlets Klaus Ostermann, Uni Marburg Based on slides by Anders Møller & Michael I. Schwartzbach Objectives How to program Web applications using servlets Advanced concepts,

More information

To create a view for students, staffs and courses in your departments using servlet/jsp.

To create a view for students, staffs and courses in your departments using servlet/jsp. Aim To create a view for students, staffs and courses in your departments using servlet/jsp. Software Requirements: Java IDE Database Server JDK1.6 Netbean 6.9/Eclipse MySQL Tomcat/Glassfish Login Form

More information

CIS 455 / 555: Internet and Web Systems

CIS 455 / 555: Internet and Web Systems 1 Background CIS 455 / 555: Internet and Web Systems Spring, 2010 Assignment 1: Web and Application Servers Milestone 1 due February 3, 2010 Milestone 2 due February 15, 2010 We are all familiar with how

More information

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS DATE: 30.9.11 Aim: To create a servlet program to display the students marks Hardware requirements: Intel Core 2 Quad 2GB RAM Software requirements:

More information

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response:

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response: Managing Cookies Cookies Cookies are a general mechanism which server side applications can use to both store and retrieve information on the client side Servers send cookies in the HTTP response and browsers

More information

Construction d Applications Réparties / Master MIAGE

Construction d Applications Réparties / Master MIAGE Construction d Applications Réparties / Master MIAGE HTTP and Servlets Giuseppe Lipari CRiSTAL, Université de Lille February 24, 2016 Outline HTTP HTML forms Common Gateway Interface Servlets Outline HTTP

More information

Stateless -Session Bean

Stateless -Session Bean Stateless -Session Bean Prepared by: A.Saleem Raja MCA.,M.Phil.,(M.Tech) Lecturer/MCA Chettinad College of Engineering and Technology-Karur E-Mail: asaleemrajasec@gmail.com Creating an Enterprise Application

More information

Oracle Containers for J2EE

Oracle Containers for J2EE Oracle Containers for J2EE Servlet Developer's Guide 10g (10.1.3.1.0) B28959-01 October 2006 Oracle Containers for J2EE Servlet Developer s Guide, 10g (10.1.3.1.0) B28959-01 Copyright 2002, 2006, Oracle.

More information

3 The Servlet Life Cycle

3 The Servlet Life Cycle 3 The Servlet Life Cycle In this chapter: The Servlet Alternative Servlet Reloading Init and Destroy Single-Thread Model Background Processing Last Modified Times The servlet life cycle is one of the most

More information

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty 1 Servlet 1.1 Web Web WWW HTML CGI Common Gateway Interface Web HTML Web Web CGI CGI CGI Perl, PHP C Java Applet JavaScript Web CGI HTML 1.2 Servlet Java Servlet Servlet CGI Web CGI 1 Java Java JVM Java

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

The Structure and Components of

The Structure and Components of Web Applications The Structure and Components of a JEE Web Application Sample Content garth@ggilmour.com The Structure t of a Web Application The application is deployed in a Web Archive A structured jar

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

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

HTTP. HTTP HTML Parsing. Java

HTTP. HTTP HTML Parsing. Java ђѕђяѡъ ьэющ HTTP HTTP TCP/IP HTTP HTTP HTML Parsing HTTP HTTP GET < > web servers GET HTTP Port 80 HTTP GOOGLE HTML HTTP Port 80 HTTP URL (Uniform Resource Locator) HTTP URL http://www.cs.tau.ac.il:80/cs/index.html

More information

Session 20 Data Sharing Session 20 Data Sharing & Cookies

Session 20 Data Sharing Session 20 Data Sharing & Cookies Session 20 Data Sharing & Cookies 1 Reading Shared scopes Java EE 7 Tutorial Section 17.3 Reference http state management www.ietf.org/rfc/rfc2965.txt Cookies Reading & Reference en.wikipedia.org/wiki/http_cookie

More information

China Jiliang University Java. Web Programming in Java. Java Servlet Programming. Java Web Applications, Helmut Dispert

China Jiliang University Java. Web Programming in Java. Java Servlet Programming. Java Web Applications, Helmut Dispert Java Web Programming in Java Java Servlet Programming Java 2 Platform Editions JavaCard Java Technology Enabled Devices Java Technology Enabled Desktop Workgroup Server High-End Server Micro Edition Standard

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

First Servlets. Chapter. Topics in This Chapter

First Servlets. Chapter. Topics in This Chapter First Servlets Chapter Topics in This Chapter The basic structure of servlets A simple servlet that generates plain text The process of compiling, installing, and invoking servlets A servlet that generates

More information

SDN Community Contribution

SDN Community Contribution SDN Community Contribution (This is not an official SAP document.) Disclaimer & Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces

More information

CHAPTER 2: A FAST INTRODUCTION TO BASIC SERVLET PROGRAMMING

CHAPTER 2: A FAST INTRODUCTION TO BASIC SERVLET PROGRAMMING Taken from More Servlets and JavaServer Pages by Marty Hall. Published by Prentice Hall PTR. For personal use only; do not redistribute. For a complete online version of the book, please see http://pdf.moreservlets.com/.

More information

Introduction to Server-Side Technologies

Introduction to Server-Side Technologies Introduction to Java Servlets Table of Contents Introduction to Server-Side Technologies Dynamic Generation of Web Pages Basic Technology Behind Dynamic Web Pages Getting Started with Java Servlets Installing

More information

UNIT 1 SERVLET PROGRAMMING

UNIT 1 SERVLET PROGRAMMING UNIT 1 SERVLET PROGRAMMING Servlet Programming Structure Page Nos. 1.0 Introduction 5 1.1 Objectives 5 1.2 How to install Servlet Engine/Web Server 6 1.3 Your First Servlet 7 1.4 Servlet Life Cycle 9 1.5

More information

J2ME With Database Connection Program

J2ME With Database Connection Program J2ME With Database Connection Program Midlet Code: /* * To change this template, choose Tools Templates * and open the template in the editor. package hello; import java.io.*; import java.util.*; import

More information

Chapter - 1 JAVA RMI

Chapter - 1 JAVA RMI Remote Method Invocation : Chapter - 1 JAVA RMI RMI is the technology used to create distributed Java applications. The methods of remote Java objects (objects that have methods on different virtual machines

More information

Server Side Internet Programming

Server Side Internet Programming Server Side Internet Programming DD1335 (Lecture 6) Basic Internet Programming Spring 2010 1 / 53 Server Side Internet Programming Objectives The basics of servlets mapping and configuration compilation

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

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

Development of the Security Framework based on OWASP ESAPI for JSF2.0

Development of the Security Framework based on OWASP ESAPI for JSF2.0 Development of the Security Framework based on OWASP ESAPI for JSF2.0 Autor Website http://www.security4web.ch 14 May 2013 1. Introduction... 3 2. File based authorization module... 3 2.1 Presentation...

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

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

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