Servletek, J2EE. Több réteg! architektúrák

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Servletek, J2EE. Több réteg! architektúrák"

Transcription

1 Servletek, J2EE 2 Több réteg! architektúrák Kommunikációs minták Client- Server 3-Tier Web Application Web Services Hybrid P2P Fractal

2 3 Web alkalmazások Business Systems DB Server App Server Web Server Browser Client J2EE J2SE/ J2ME Web Application 4 Web services Bus. Sys. DB App Web Browser XML (UDDI, SOAP) Context and Identity (LDAP, Policy, Liberty) J2EE J2SE/ J2ME Web Service

3 5 Servletek dinamikus html tartalom generálás üzleti alkalmazás web interfészének kialakítása servletek Java technológia webszerver kiterjesztése 6 Servletek vs. CGI Servlet el!nyök Hatékonyság Kényelem Platform és szerver független Session management Request Request CGI1 CGI1 Biztonságos Request CGI2 Request CGI2 Request Request CGI1 CGI1 CGI CGI Based Webserver Child Child for for CGI1 CGI1 Child Child for for CGI2 CGI2 Child Child for for CGI1 CGI1 Request Request Servlet1 Servlet1 Request Request Servlet2 Servlet2 Request Servlet1 Servlet Servlet Based Based Webserver Webserver Servlet1 Servlet1 JVM JVM Servlet2 Servlet2

4 7 J2EE konténerek Komponensek végrehajtási környezete Egyszer" API Transzparensek Enterprise API biztosítása Applet Container Web Container EJB Container Applet HTTP/ JSP Servlet EJB HTTPS RMI J2SE App Client Container App Client HTTP/ HTTPS JNDI J2SE RMI JNDI JMS RMI/IIOP JMS JDBC JTA JavaMail JAF RMI/IIOP JDBC JNDI JMS JTA JavaMail JAF RMI/IIOP JDBC J2SE J2SE Database 76 8 Servlet m!ködése Server Machine Servlet Java Class Client Machine Web Browser HTML doget or dopost HTML Web Server Init Service HTML HTML doget dopost Destroy

5 9 Servlet osztályok Servlet Basic Servlet Layer Method: service ServletRequest ServletResponse HttpServlet Methods: Service doget dopost init destroy etc. Http Servlet Layer HttpServletRequest HttpServletResponse MyServlet Methods: doget dopost init destroy etc. Your Servlet Code 10 doget, dopost public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException public void doput(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException HttpServletRequest kérés paraméterei, http fejléc mez!k, post adatok HttpServletResponse válasz fejléc, html tartalom

6 11 Servlet output public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title>first Servlet program</title></head>"); out.println("<body>"); out.println("<h1>welcome to Servlets</H1>"); out.println("</body>"); out.println("</html>"); out.close(); 12 Servlet konténerek Apache Tomcat (referencia implementáció) Allaire JRun Gefion LiteWebServer Sun Java Web Server

7 13 Servlet kód template import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ServletTemplate extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { // Use "request" to read incoming HTTP headers // (e.g. cookies) and HTML form data (e.g. data the user // entered and submitted). // Use "response" to specify the HTTP response status // code and headers (e.g. the content type, cookies). PrintWriter out = response.getwriter(); // Use "out" to send content to browser 14 Servlet példa import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head>"); out.println("<title>hola</title>"); out.println("</head>"); out.println("<body bgcolor=\"white\">"); out.println("<h1> Hi </h1>"); out.println("</body>"); out.println("</html>");

8 15 A servlet telepítése Context web application <inst.dir>/conf/server.xml <inst.dir>/webapps dir mine mine/web-inf mine/web-inf/classes mine/web-inf/lib mine/web-inf/web.xml <inst.dir>/tomcat-docs/appdev/ web.xml.txt 16 web.xml <display-name>my Web Application</display-name> <description> Examples by Me </description> [...] <context-param> <param-name>webmaster</param-name> <description> The address of the administrator to whom questions and comments about this application should be addressed. </description> </context-param> <servlet> <servlet-name>hi</servlet-name> <description> Testing </description> <servlet-class>hi</servlet-class> </servlet> <servlet-mapping> <servlet-name>hi</servlet-name> <url-pattern>/hi</url-pattern> </servlet-mapping>

9 17 Servlet életciklus // load the servlet class and setup request, response objects Servlet servlet = ServletRequest request = ServletResponse response = // initialise servlet ServletConfig config = servlet.getservletconfig(); servlet.init(config); // service zero or more requests while ( more requests ) // invoke servlet to process request servlet.service(request, service); Call to methods doget(), dopost() in the user defined servlet class // cleanup after service servlet.destroy(); Unlike CGI a single servlet can service several requests. In CGI, server invokes a separate process for each request. Servlets therefore reduce server load CCTM: Course material developed by James King 18 Inicializálás import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** Example using servlet initialization. Here, the message * to print and the number of times the message should be * repeated is taken from the init parameters. */ public class ShowMessage extends HttpServlet { private String message; private String defaultmessage = "No message."; private int repeats = 1; public void init(servletconfig config) throws ServletException { // Always call super.init super.init(config); message = config.getinitparameter("message"); if (message == null) { message = defaultmessage; try { String repeatstring = config.getinitparameter("repeats"); repeats = Integer.parseInt(repeatString); catch(numberformatexception nfe) { // NumberFormatException handles case where repeatstring // is null *and* case where it is something in an // illegal format. Either way, do nothing in catch, // as the previous value (1) for the repeats field will // remain valid because the Integer.parseInt throws // the exception *before* the value gets assigned // to repeats. <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2// EN" " <web-app> <servlet> <servlet-name> ShowMsg </servlet-name> <servlet-class> coreservlets.showmessage </servlet-class> <init-param> <param-name> message </param-name> <param-value> Shibboleth </param-value> </init-param> <init-param> <param-name> repeats </param-name> <param-value> 5 </param-value> </init-param> </servlet> </web-app> web.xml

10 19 Inicializálás (példa) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** Example using servlet initialization and the * getlastmodified method. */ public class LotteryNumbers extends HttpServlet { private long modtime; private int[] numbers = new int[10]; /** The init method is called only when the servlet * is first loaded, before the first request * is processed. */ public void init() throws ServletException { // Round to nearest second (ie 1000 milliseconds) modtime = System.currentTimeMillis()/1000*1000; for(int i=0; i<numbers.length; i++) { numbers[i] = randomnum(); public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); String title = "Your Lottery Numbers"; out.println(servletutilities.headwithtitle(title) +"<BODY BGCOLOR=\"#FDF5E6\">\n" + "<H1 ALIGN=CENTER>" + title + "</H1>\n" + "<B>Based upon extensive research of " + "astro-illogical trends, psychic farces, " + "and detailed statistical claptrap, " + "we have chosen the " + numbers.length + " best lottery numbers for you.</b>" + "<OL>"); for(int i=0; i<numbers.length; i++) { out.println(" <LI>" + numbers[i]); out.println("</ol>" + "</BODY></HTML>"); 20 Inicializálás (példa folyt.) /** The standard service method compares this date * against any date specified in the If-Modified-Since * request header. If the getlastmodified date is * later, or if there is no If-Modified-Since header, * the doget method is called normally. But if the * getlastmodified date is the same or earlier, * the service method sends back a 304 (Not Modified) * response, and does <B>not</B> call doget. * The browser should use its cached version of * the page in such a case. */ public long getlastmodified(httpservletrequest request) { return(modtime); // A random int from 0 to 99. private int randomnum() { return((int)(math.random() * 100));

11 21 HttpServletRequest osztály String getmethod() obtain the HTTP request is it a GET or POST String getparameter(string name) - get a parameter (covered later) String getremotehost() - client s host name String getremoteaddr() - IP address of client String getservername() - servers name int getserverport() - port on which server was initially contacted on (8080 is usually intranet only and not accessible from outside) String getheader("user-agent") - name of client s web browser String getheader("referer") - URL of page that called the servlet some more methods HttpServletRequest példa import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ServEnvData extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title>environment Data</TITLE></HEAD>"); out.println("<body>"); out.println("<h1>servlet Environment</H1>"); out.println("<b>method:</b>"+request.getmethod()+"<br>"); out.println("<b>client Host:</B>"+request.getRemoteHost()+"<BR>"); out.println("<b>client's IP Address:</B>"+request.getRemoteAddr()+"<BR>"); out.println("<b>server Name:</B>"+request.getServerName()+"<BR>"); out.println("<b>server Port:</B>"+request.getServerPort()+"<BR>"); out.println("<b>client's Browser:</B>"+request.getHeader("User-Agent")+"<BR>"); out.println("<b>client's URL:</B>"+request.getHeader("Referer")+"<BR>"); out.println("</body>"); out.println("</html>"); out.close();

12 23 HttpServletRequest példa (folyt.) 24 HttpServletResponse osztály void response.addcookie(cookie cookie) void response.senderror(int status) - standard HTTP status codes void response.sendstatus(int status) - send HTTP status codes that are not errors void response.sendredirect(string location) - sends a redirect response to the client some more methods...

13 25 URL és form paraméterek <a href=" click here for a parameter example! </a> String parameter=request.getparameter("p1"); <a href=" p1=hello&p2=goodbye"> click here for a parameter example! </a> Enumeration p=request.getparameternames(); while (p.hasmoreelements()) { String n=(string)p.nextelement(); String v=request.getparameter(n); out.println("parameter name is "+n+" parameter value" +v+"<br>"); 26 Kiszolgálás több szálon servlet meghívása konkurrens kérésekb!l globális változók kezelése?

14 27 Nem megfelel" megoldás (pl.) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class multi extends HttpServlet { int count=0; public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title> Thread UNSAFE example </TITLE> </HEAD> "); out.println("<body>"); out.println("<h1> old count is "+count+"</h1>"); count=count+1; try { Thread.sleep(4000); catch (Exception e) { out.println("<h1> new count is "+count+"</h1>"); out.println("</body>"); out.println("</html>"); 28 Megoldások nincsenek globális adatok session és cookie kezelés tárolás kliens oldalon kritikus szakasz megvalósítás szinkronizálás

15 29 Synchronized (pl.) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class multi extends HttpServlet { int count=0; Object s=new Object(); public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title> Thread UNSAFE example </TITLE> </HEAD> "); out.println("<body>"); synchronized (s) { out.println("<h1> old count is "+count+"</h1>"); 30 Perzisztens adatok Állapot meg!rzése servlet újratöltések és inicializálások között Szerver részér!l meghatározatlan újratöltési id!pontok

16 31 Probléma (pl.) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class global extends HttpServlet { int count=0; public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title> Global Data Example </TITLE> </HEAD> "); out.println("<body>"); out.println("<h1> old count is "+count+"</h1>"); 32 Megoldás HttpServletContext attribútumok requestben elérhet!k újra fordításkor elveszik

17 33 Megoldás (pl.) import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class context extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { Integer count=new Integer(0); response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head><title> Global Data Example </TITLE> </HEAD> "); out.println("<body>"); Date d=new Date(); out.println("current time is "+d); ServletContext s=getservletcontext(); count=(integer)s.getattribute("count"); if (count==null) { count=new Integer(0); s.setattribute("count",count); int c=count.intvalue(); out.println("<h1> old count is "+c+"</h1>"); c=c+1; out.println("<h1> new count is "+c+"</h1>"); count=new Integer(c); s.setattribute("count",count); out.println("</body>"); out.println("</html>"); 34 Kliens oldali állapottárolás session kliens életciklus több kérés-válasz páron keresztül szerver adminisztálja egyedi azonosító törlés, élettartam lejárta

18 35 Session ID kezelés URL generálás rejtett form mez! cookie SSL session id 36 Cookie HTML header név, érték (URL) Set-cookie: FavColours=Blue; Max-age=60; Domain=.unl.ac.uk ; Path= / ; korlátozások 20 cookie per webszerver 4 KB méret

19 37 HttpSession nagy mennyiség" struktúrált adat tárolása attribútumok Java objects HttpServletRequest 38 HttpSession (folyt.)... HttpSession s= request.getsession(true); s.setmaxinactiveinterval(60); Integer value=new Integer(0); value=(integer)s.getattribute("value"); if (value==null) { value=new Integer(0); s.setattribute("value",value); out.println("<h1> The session has id "+s.getsessionid()+"</h1>"); out.println("<h1> old value is "+value+"</h1>"); value=new Integer(value.intValue()+1); out.println("<h1> new count is "+ s.getattribute("value") +"</H1>"); s.setattribute("value",value);...

20 39 Cookie kezelés Lekérdezés public void doget(httpservletrequest request, HttpServletResponse response) {. Cookie cookie = null; Cookie[] cookies = request.getcookies(); if (cookiearr!= null) { for (int i = 0; i < cookies.length; i++) { cookie = cookies[i]; String name = cookie.getname(); if (name.equals( FavColours")) { out.println(cookie.value());. Beállítás cookie = new Cookie( FavColours, Blue ); cookie.setmaxage(600); response.addcookie(cookie); 40 Servlet debuggolás wget curl WebClient

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

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

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 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

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

&' () - #-& -#-!& 2 - % (3 3 !!! + #%!%,)& ! # * +, ! "# # $! " &' ()!"#$$&$'(!!! ($) * + #!,)& - #-& +"- #!(-& #& #$.//0& -#-!& #-$$!& 1+#& 2-2" (3" 3 * * +, - -! #.// HttpServlet $ Servlet 2 $"!4)$5 #& 5 5 6! 0 -.// # 1 7 8 5 9 2 35-4 2 3+ -4 2 36-4 $

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

AN OVERVIEW OF SERVLET AND JSP TECHNOLOGY

AN OVERVIEW OF SERVLET AND JSP TECHNOLOGY AN OVERVIEW OF SERVLET AND JSP TECHNOLOGY Topics in This Chapter Understanding the role of servlets Building Web pages dynamically Looking at servlet code Evaluating servlets vs. other technologies Understanding

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

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

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

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

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

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

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

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

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

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

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

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps. About the Tutorial Servlets provide a component-based, platform-independent method for building Webbased applications, without the performance limitations of CGI programs. Servlets have access to the entire

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Handling Cookies. For live Java EE training, please see training courses at

Handling Cookies. For live Java EE training, please see training courses at Edited with the trial version of 2012 Marty To Hall remove this notice, visit: Handling Cookies Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/csajsp2.html

More information

A Servlet-Based Search Engine. Introduction

A Servlet-Based Search Engine. Introduction A Servlet-Based Search Engine Introduction Architecture Implementation Summary Introduction Pros Suitable to be deployed as a search engine for a static web site Very efficient in dealing with client requests

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

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

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

J2EE Packaging and Deployment

J2EE Packaging and Deployment Summary of Contents Introduction 1 Chapter 1: The J2EE Platform 9 Chapter 2: Directory Services and JNDI 39 Chapter 3: Distributed Computing Using RMI 83 Chapter 4 Database Programming with JDBC 157 Chapter

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

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

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

Distributed Systems 1

Distributed Systems 1 95-702 Distributed Systems 1 Joe Intro Syllabus highlights 95-702 Distributed Systems 2 Understand the HTTP application protocol Request and response messages Methods / safety / idempotence Understand

More information

UNIT-VI. HttpServletResponse It extends the ServletResponse interface to provide HTTP-specific functionality in sending a response.

UNIT-VI. HttpServletResponse It extends the ServletResponse interface to provide HTTP-specific functionality in sending a response. UNIT-VI javax.servlet.http package: The javax.servlet.http package contains a number of classes and interfaces that describe and define the contracts between a Servlet class running under the HTTP protocol

More information

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

This course is intended for Java programmers who wish to write programs using many of the advanced Java features. COURSE DESCRIPTION: Advanced Java is a comprehensive study of many advanced Java topics. These include assertions, collection classes, searching and sorting, regular expressions, logging, bit manipulation,

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

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

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

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

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

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

Table of Contents Fast Track to JSF 2

Table of Contents Fast Track to JSF 2 Table of Contents Fast Track to JSF 2 Fast Track to JavaServer Faces (JSF 2) 1 Workshop Overview / Student Prerequisites 2 Workshop Agenda 3 Typographic Conventions 4 Labs 5 Release Level 6 Session 1:

More information

ProgramvaruUtveckling för Stora System F2

ProgramvaruUtveckling för Stora System F2 ProgramvaruUtveckling för Stora System F2 Lecture 2 First hour requirements engineering Second Hour webservers and Tomcat 1 A nice video http://www.youtube.com/watch?v=x2wdvg0dvne Stop after two minutes

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

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

IBM WebSphere Application Server. J2EE Programming Model Best Practices

IBM WebSphere Application Server. J2EE Programming Model Best Practices IBM WebSphere Application Server J2EE Programming Model Best Practices Requirements Matrix There are four elements of the system requirements: business process and application flow dynamic and static aspects

More information

Enterprise Java and Rational Rose - Part II

Enterprise Java and Rational Rose - Part II Enterprise Java and Rational Rose - Part II by Khawar Ahmed Technical Marketing Engineer Rational Software Loïc Julien Software Engineer Rational Software This is the second installment of a twopart series

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

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

Table of Contents. Introduction... xxi

Table of Contents. Introduction... xxi Introduction... xxi Chapter 1: Getting Started with Web Applications in Java... 1 Introduction to Web Applications... 2 Benefits of Web Applications... 5 Technologies used in Web Applications... 5 Describing

More information

Web Technology for IE 20 November ISE 582: Information Technology for Industrial Engineering

Web Technology for IE 20 November ISE 582: Information Technology for Industrial Engineering ISE 582: Information Technology for Industrial Engineering Instructor: Elaine Chew University of Southern California Department of Industrial and Systems Engineering Lecture 11 JAVA Cup 10: Making Connections

More information

GENERATING THE SERVER RESPONSE: HTTP STATUS CODES

GENERATING THE SERVER RESPONSE: HTTP STATUS CODES GENERATING THE SERVER RESPONSE: HTTP STATUS CODES Topics in This Chapter Format of the HTTP response How to set status codes What the status codes are good for Shortcut methods for redirection and error

More information

XmlEngine user s manual

XmlEngine user s manual XmlEngine user s manual 7 th April 2006 Revision 1.0 Visit us at www.openbravo.com Table of Contents I.Introduction... 3 II.Requirements... 4 III.License... 5 IV.Installation... 6 V.System overview...

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Length: 4 days Description: This course presents several advanced topics of the Java programming language, including Servlets, Object Serialization and Enterprise JavaBeans. In

More information

Wireless Java Technology

Wireless Java Technology Wireless Java Technology Pao-Ann Hsiung National Chung Cheng University Ref: http://developers.sun.com/techtopics/mobility/learning/tutorial/ 1 Contents Overview of Java 2 Platform Overview of J2ME Scope

More information

Updates. stmt.executeupdate( update... ); For updates/inserts/deletes, use. con.commit();

Updates. stmt.executeupdate( update... ); For updates/inserts/deletes, use. con.commit(); Web Programming with Java Servlets Leonidas Fegaras University of Texas at Arlington Web Data Management and XML L3: Web Programming with Servlets 1 Working with ResultSet ResultSet: a table of data representing

More information

core programming Servlets Marty Hall, Larry Brown

core programming Servlets Marty Hall, Larry Brown core programming Servlets 1 2001-2003 Marty Hall, Larry Brown http:// 2 Servlets Agenda Overview of servlet technology First servlets Handling the client request Form data HTTP request headers Generating

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

Developing a Mobile Web-based Application with Oracle9i Lite Web-to-Go

Developing a Mobile Web-based Application with Oracle9i Lite Web-to-Go Developing a Mobile Web-based Application with Oracle9i Lite Web-to-Go Christian Antognini Trivadis AG Zürich, Switzerland Introduction More and more companies need to provide their employees with full

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

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

The Servlet as Client

The Servlet as Client 05Birnam.3 10/9/00 1:27 PM Page 97 5 The Servlet as Client QUICK START TECHNOLOGY OVERVIEW PROGRAMMING CONCEPTS THE UNITDBSERVLET USING RMI FROM A SERVLET HANDLING ERRORS AND RECONNECTION TO REMOTE OBJECTS

More information

Java Server Pages JSP

Java Server Pages JSP Java Server Pages JSP Agenda Introduction JSP Architecture Scripting Elements Directives Implicit Objects 2 A way to create dynamic web pages Introduction Separates the graphical design from the dynamic

More information

Combined Java Web Example: Servlets, JDBC and Graphics

Combined Java Web Example: Servlets, JDBC and Graphics A sample Training Module from our course WELL HOUSE CONSULTANTS LTD 404, The Spa Melksham, Wiltshire SN12 6QL United Kingdom PHONE: 01225 708225 FACSIMLE 01225 707126 EMAIL: info@wellho.net 2004 Well House

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

Penetration: from application down to OS

Penetration: from application down to OS April 8, 2009 Penetration: from application down to OS Getting OS access using IBM Websphere Application Server vulnerabilities Digitаl Security Research Group (DSecRG) Stanislav Svistunovich research@dsecrg.com

More information

Chapter 11 Upgrading Servlets to Agents

Chapter 11 Upgrading Servlets to Agents Chapter 11 Upgrading Servlets to Agents This chapter is designed especially for two groups of people: (1) Those interested in learning more about the relationship of Servlets to Agents; and (2) those of

More information

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem ECS-503 Object Oriented Techniques UNIT-5 Course Jdbc... 1 Servlets... 17 JDBC --> The database is the heart of any enterpries system which is used to store and retrieve the data of enterprise more efficiently.

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

Java Servlet Specification, v2.2

Java Servlet Specification, v2.2 Java Servlet Specification, v2.2 Final Release December 17th, 1999 James Duncan Davidson Danny Coward Please send all comments to servletapi-feedback@eng.sun.com. Java Servlet Specification ("Specification")

More information

Web Programming with Java Servlets

Web Programming with Java Servlets Web Programming with Java Servlets Leonidas Fegaras University of Texas at Arlington Web Data Management and XML L3: Web Programming with Servlets 1 Database Connectivity with JDBC The JDBC API makes it

More information

Generating the Server Response:

Generating the Server Response: 2009 Marty Hall Generating the Server Response: HTTP Status Codes Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/csajsp2.html p 2 Customized Java EE

More information

presentation DAD Distributed Applications Development Cristian Toma

presentation DAD Distributed Applications Development Cristian Toma Lecture 12 S4 - Core Distributed Middleware Programming in JEE Distributed Development of Business Logic Layer presentation DAD Distributed Applications Development Cristian Toma D.I.C.E/D.E.I.C Department

More information

Jawaharlal Nehru Engineering College

Jawaharlal Nehru Engineering College Jawaharlal Nehru Engineering College Laboratory Manual Web Information System For Final Year Students Dept: Information Technology FOREWORD It is my great pleasure to present this laboratory manual for

More information

Sun Java SystemWeb Server 6.1 SP9 Programmer's Guide to Web Applications

Sun Java SystemWeb Server 6.1 SP9 Programmer's Guide to Web Applications Sun Java SystemWeb Server 6.1 SP9 Programmer's Guide to Web Applications Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. Part No: 820 5711 February 2008 Copyright 2008 Sun Microsystems,

More information

UNIVERSITY OF CINCINNATI

UNIVERSITY OF CINCINNATI UNIVERSITY OF CINCINNATI Date: I,, hereby submit this work as part of the requirements for the degree of: in: It is entitled: This work and its defense approved by: Chair: AN XML-BASED COURSE REGISTRATION

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

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

Table of Contents Fast Track to Java EE 5 with Servlets/JSP and JDBC

Table of Contents Fast Track to Java EE 5 with Servlets/JSP and JDBC Table of Contents Fast Track to Java EE 5 with Servlets/JSP and JDBC Fast Track to Java EE 5 with Servlets/JSP and JDBC 1 Workshop Overview 2 Workshop Objectives 3 Workshop Agenda 4 Typographic Conventions

More information

Servlets JSP EJB. Part III. Java Platform, Enterprise Edition (Java EE)

Servlets JSP EJB. Part III. Java Platform, Enterprise Edition (Java EE) Part III Java Platform, Enterprise Edition (Java EE) 65 Java Platform, Enterprise Edition (Java EE) Java Servlets and JSP pages in web access layer Enterprise JavaBeans 3.0 for implementing business logic

More information

Java Servlet Specification Version 2.3

Java Servlet Specification Version 2.3 Java Servlet Specification Version 2.3 Please send technical comments to: servletapi-feedback@eng.sun.com Please send business comments to: danny.coward@sun.com Final Release 8/13/01 Danny Coward (danny.coward@sun.com)

More information

(Objective-CS506 Web Design and Development)

(Objective-CS506 Web Design and Development) Question No: 1 ( Marks: 1 ) - Please choose one allow the websites to store information on a client machine and later retrieve it. 1. Cookies (Page: 297) 2. Sessions 3. Panel 4. Servlet Question No: 2

More information

INTRODUCTION 1.1 THE WORLD WIDE WEB. Unit Structure

INTRODUCTION 1.1 THE WORLD WIDE WEB. Unit Structure 1 1 INTRODUCTION Unit Structure 1.1 The World Wide Web 1.2 World Wide Web Architecture 1.3 Web search engine 1.4 Web Crawling 1.5 Web indexing 1.6 Web Searching 1.7 Search Engine Optimization (SEO) and

More information

Java 2 Platform, Enterprise Edition: Platform and Component Specifications

Java 2 Platform, Enterprise Edition: Platform and Component Specifications Table of Contents Java 2 Platform, Enterprise Edition: Platform and Component Specifications By Bill Shannon, Mark Hapner, Vlada Matena, James Davidson, Eduardo Pelegri-Llopart, Larry Cable, Enterprise

More information

Web Based Solutions. Gerry Seidman. IAM Consulting

Web Based Solutions. Gerry Seidman. IAM Consulting Web Based Solutions Gerry Seidman Internet Access Methods seidman@iamx.com http://www.iam-there.com 212-580-2700 IAM Consulting seidman@iamx.com http://www.iamx.com 212-580-2700 (c) IAM Consulting Corp.

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

Deccansoft Software Services. J2EE Syllabus

Deccansoft Software Services. J2EE Syllabus Overview: Java is a language and J2EE is a platform which implements java language. J2EE standard for Java 2 Enterprise Edition. Core Java and advanced java are the standard editions of java whereas J2EE

More information

Servlets.

Servlets. Servlets Servlets Servlets are modules that extend Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used

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