JAVA SERVLET. Server-side Programming ADVANCED FEATURES

Size: px
Start display at page:

Download "JAVA SERVLET. Server-side Programming ADVANCED FEATURES"

Transcription

1 JAVA SERVLET Server-side Programming ADVANCED FEATURES 1

2 AGENDA RequestDispacher SendRedirect ServletConfig ServletContext ServletFilter SingleThreadedModel Events and Listeners Servlets & Database 2

3 REQUESTDISPATCHER Forward: facility of dispatching the request to another resource public void forward(servletrequest request,servletresponse response) throws ServletException,java.io.IOException Include: can also be used to include the content of another resource public void include(servletrequest request,servletresponse response) throws ServletException,java.io.IOException RequestDispatcher rd=request.getrequestdispatcher( Myservlet"); rd.forward(request, response); 3

4 REQUESTDISPATCHER SRC: 4

5 REQUESTDISPATCHER public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); String username=request.getparameter("username"); String password=request.getparameter( password"); if(username.equals( abc") && password.equals( xyz") { RequestDispatcher rd=request.getrequestdispatcher( LoginSuccessServlet"); rd.forward(request, response); else{ out.print( Sorry User Name or Password Error!"); RequestDispatcher rd=request.getrequestdispatcher("/index.html"); rd.include(request, response); 5

6 SENDREDIRECT Method of HttpServletResponse interface public void sendredirect(string URL)throws IOException; response.sendredirect(" 6

7 SENDREDIRECT forward() method It works at server side. It sends the same request and response objects to another servlet. It can work within the server only. Request method sendredirect() method It works at client side. It always sends a new request. It can be used within and outside the server. Response method 7

8 SERVLETCONFIG An object of ServletConfig is created by the web container for each servlet. This object can be used to get configuration information from Annotation web.xml file Server interface/tool Don't need to change the servlet ServletConfig config=getservletconfig(); 8

9 SERVLETCONFIG public String getinitparameter(string name) public Enumeration getinitparameternames() public String getservletname() public ServletContext getservletcontext() 9

10 SERVLETCONFIG Defining init urlpatterns = "/ParameterServlet", initparams = = " ", value = = "phone", value = ") ) Accessing init Parameters private String , public void init(servletconfig config) throws ServletException { = config.getinitparameter(" "); phone = config.getinitparameter("phone"); 10

11 SERVLETCONFIG Web.xml <web-app> <servlet>... <servlet-name>parameterservlet</servlet-name> <servlet-class> myservlet.parameterservlet</servlet-class> <init-param> <param-name> </param-name> </init-param>... </servlet> </web-app> 11

12 SERVLETCONTEXT Created by the web container at time of deploying the project. Only one ServletContext object per web application. This object can be used to get configuration information from Annotation web.xml file Server interface/tool Don't need to change the servlet ServletContext application=getservletcontext(); 12

13 SERVLETCONTEXT public String getinitparameter(string name) public Enumeration getinitparameternames() public void setattribute(string name,object object) public Object getattribute(string name) public void removeattribute(string name) 13

14 SERVLETCONTEXT Accessing init Parameters private String , public void init(servletconfig config) throws ServletException { ServletContext ctx = config.getservletcontext(); = ctx.getinitparameter(" "); phone = ctx.getinitparameter("phone"); 14

15 SERVLETCONTEXT Web.xml <web-app> <context-param> <param-name> </param-name> </context-param> <context-param> <param-name>phone</param-name> <param-value> </param-value> </context-param> <servlet> </servlet> </web-app> 15

16 FILTER A filter is an object that can transform the header and content (or both) of a request or response. Authentication Filters. Data compression Filters. Encryption Filters. 16

17 FILTER void init(filterconfig config) throws ServletException void destroy() void dofilter(servletrequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException 17

18 FILTER public class LoginFilter implements Filter { public void init(filterconfig config) throws ServletException { public void dofilter(servletrequest request, ServletResponse response, FilterChain chain) throws java.io.ioexception, ServletException { String password=req.getparameter("password"); if(password.equals("admin")){ chain.dofilter(req, resp);//sends request to next resource else{ out.print("username or password error!"); RequestDispatcher rd=req.getrequestdispatcher("index.html"); rd.include(req, resp); public void destroy( ) { 18

19 FILTER <filter> <filter-name>loginfilter</filter-name> <filter-class>loginfilter</filter-class> <init-param> <param-name>test-param</param-name> <param-value>initialization Paramter</param-value> </init-param> </filter> <filter-mapping> <filter-name>loginfilter</filter-name> <url-pattern>/myservlet</url-pattern> </filter-mapping> 19

20 SINGLETHREADMODEL Marker Interface Ensures that servlets handle only one request at a time. you are guaranteed that no two threads will execute concurrently in the servlet's service method. 20

21 EVENT AND LISTENER The servlet specification includes the capability to track key events in your Web applications through event listeners. Three levels of servlet events Servlet context level Session level Request level Each of these two levels has two event categories: Lifecycle changes Attribute changes 21

22 EVENT AND LISTENER ServletRequestListener ServletRequestAttributeListener ServletContextListener ServletContextAttributeListener HttpSessionListener HttpSessionAttributeListener 22

23 EVENT AND LISTENER Listener that tracks the number of concurrent users HttpSessionListener interface void sessioncreated(httpsessionevent evt) void sessiondestroyed(httpsessionevent evt) 23

24 EVENT AND LISTENER public class CountUserListener implements HttpSessionListener{ ServletContext ctx=null; static int total=0,current=0; public void sessioncreated(httpsessionevent e) { total++; current++; ctx=e.getsession().getservletcontext(); ctx.setattribute("totalusers", total); ctx.setattribute("currentusers", current); public void sessiondestroyed(httpsessionevent e) { current--; ctx.setattribute("currentusers",current); 24

25 EVENT AND LISTENER public class First extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); String n=request.getparameter("username"); out.print("welcome "+n); HttpSession session=request.getsession(); session.setattribute("uname",n); ServletContext ctx=getservletcontext(); int t=(integer)ctx.getattribute("totalusers"); int c=(integer)ctx.getattribute("currentusers"); out.print("<br>total users= "+t); out.print("<br>current users= "+c); out.print("<br><a href='logout'>logout</a>"); out.close(); 25

26 EVENT AND LISTENER public class LogoutServlet extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); HttpSession session=request.getsession(false); session.invalidate(); out.print("you are successfully logged out"); out.close(); 26

27 EVENT AND LISTENER <web-app version="2.5" > <listener> <listener-class>countuserlistener</listener-class> </listener> <servlet> <servlet-name>first</servlet-name> <servlet-class>first</servlet-class> </servlet> <servlet> <servlet-name>logoutservlet</servlet-name> <servlet-class>logoutservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>first</servlet-name> <url-pattern>/first</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>logoutservlet</servlet-name> <url-pattern>/logout</url-pattern> </servlet-mapping> </web-app> 27

28 EVENT AND LISTENER <form action= First"> Name:<input type="text" name="username"><br> Password:<input type="password" name="userpass"><br> <input type="submit" value="login"/> </form> 28

29 SERVLETS - DATABASE ACCESS PrintWriter out = response.getwriter(); try { String driver = "com.mysql.jdbc.driver"; String url = "jdbc:mysql://localhost:3306/students"; String username = "root"; String password = "password"; String query = "select * from mtcse"; Class.forName(driver); Connection con = DriverManager.getConnection(url, username, password); Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery(query); out.println("<table BORDER=1>"); ResultSetMetaData rsmd = rs.getmetadata(); int columncount = rsmd.getcolumncount(); out.println("<tr>"); while (rs.next()) { out.println("<tr>"); for (int i = 1; i <= columncount; i++) { if (rsmd.getcolumntype(i) == java.sql.types.integer) { out.print("<td>" + rs.getint(i)); else { out.print("<td>" + rs.getstring(i)); out.println(); out.println("</table>"); catch (ClassNotFoundException cnfe) { out.println("error loading driver: " + cnfe); catch (SQLException sqle) { out.println("error connecting: " + sqle); catch (Exception ex) { out.println("error with input: " + ex); for (int i = 1; i <= columncount; i++) { out.print("<th>" + rsmd.getcolumnname(i)); finally { out.println("</body></html>"); 29 out.println(); out.close();

30 REFERENCES

31 THANK YOU 31 SRC:

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

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

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

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

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

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

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

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

&' () - #-& -#-!& 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

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

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

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

Servlet 5.1 JDBC 5.2 JDBC

Servlet 5.1 JDBC 5.2 JDBC 5 Servlet Java 5.1 JDBC JDBC Java DataBase Connectivity Java API JDBC Java Oracle, PostgreSQL, MySQL Java JDBC Servlet OpenOffice.org ver. 2.0 HSQLDB HSQLDB 100% Java HSQLDB SQL 5.2 JDBC Java 1. JDBC 2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Session 9. Introduction to Servlets. Lecture Objectives

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

More information

Session 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

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

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

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

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

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

(2½ hours) Total Marks: 75

(2½ hours) Total Marks: 75 (2½ hours) Total Marks: 75 N B: (1) All questions are compulsory (2) Make suitable assumptions wherever necessary and state the assumptions made (3) Answers to the same question must be written together

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

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

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

CreateServlet.java

CreateServlet.java Classes in OBAAS 1.2: -------------------- The package name is pack_bank. Create this package in java source of your project. Create classes as per the class names provided here. You can then copy the

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

CSC309: Introduction to Web Programming. Lecture 10

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

More information

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

Université Antonine - Baabda

Université Antonine - Baabda Université Antonine - Baabda Faculté d ingénieurs en Informatique, Multimédia, Systèmes, Réseaux et Télécommunications Applications mobiles (Pocket PC, etc ) Project: Manipulate School Database Préparé

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

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

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Database Access with JDBC Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Overview Overview of JDBC technology JDBC drivers Seven basic steps in using JDBC Retrieving

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

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD W HI TEPAPER www. p rogres s.com WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD In this whitepaper, we describe how to white label Progress Rollbase private cloud with your brand name by following a

More information

26/06/56. Java Technology, Faculty of Computer Engineering, KMITL 1

26/06/56. Java Technology, Faculty of Computer Engineering, KMITL 1 Engineering, KMITL 1 Agenda Including, forwarding to, and redirecting to other web resources Scope Objects Session Tracking API Servlet Listener Servlet Filter Engineering, KMITL 2 Engineering, KMITL 3

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

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

Complimentary material for the book Software Engineering in the Agile World

Complimentary material for the book Software Engineering in the Agile World Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7)

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

Oracle 1Z Java EE 6 Web Component Developer(R) Certified Expert.

Oracle 1Z Java EE 6 Web Component Developer(R) Certified Expert. Oracle 1Z0-899 Java EE 6 Web Component Developer(R) Certified Expert http://killexams.com/exam-detail/1z0-899 QUESTION: 98 Given: 3. class MyServlet extends HttpServlet { 4. public void doput(httpservletrequest

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

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

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

PARTIAL Final Exam Reference Packet

PARTIAL Final Exam Reference Packet PARTIAL Final Exam Reference Packet (Note that some items here may be more pertinent than others; you'll need to be discerning.) Example 1 - St10CommonImportTop.jsp (with comments removed)

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

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

SCWCD Study Guide Exam: CX

SCWCD Study Guide Exam: CX SCWCD Study Guide Exam: CX-310-081 Book: Head First Servlets & JSP Authors: Bryan Basham, Kathy Sierra, Bert Bates Abridger: Barney Marispini CHAPTER 1 (Overview) HTTP HTTP stands for HyperText Transfer

More information

Oracle EXAM - 1Z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Buy Full Product

Oracle EXAM - 1Z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Buy Full Product Oracle EXAM - 1Z0-858 Java Enterprise Edition 5 Web Component Developer Certified Professional Exam Buy Full Product http://www.examskey.com/1z0-858.html Examskey Oracle 1Z0-858 exam demo product is here

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

Java Server Pages. JSP Part II

Java Server Pages. JSP Part II Java Server Pages JSP Part II Agenda Actions Beans JSP & JDBC MVC 2 Components Scripting Elements Directives Implicit Objects Actions 3 Actions Actions are XML-syntax tags used to control the servlet engine

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

Connection Pools. The ConnectionObject

Connection Pools. The ConnectionObject Connection Pools A web application that has been deployed on a server may have many clients accessing it. If each time the database connection is needed it has to be reopened, performance will degenerate

More information

Author - Ashfaque Ahmed

Author - Ashfaque Ahmed Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-1983801570) published by Create Space Independent Publishing Platform, USA Author - Ashfaque Ahmed Technical support

More information

SWE642 Oct. 22, 2003

SWE642 Oct. 22, 2003 import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.arraylist; DataServlet.java /** * First servlet in a two servlet application. It is responsible

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

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

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

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

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

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

文字エンコーディングフィルタ 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

EXPERIMENT- 9. Login.html

EXPERIMENT- 9. Login.html EXPERIMENT- 9 To write a program that takes a name as input and on submit it shows a hello page with name taken from the request. And it shows starting time at the right top corner of the page and provides

More information

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu DEZVOLTAREA APLICATIILOR WEB CURS 7 Lect. Univ. Dr. Mihai Stancu S u p o r t d e c u r s suport (Beginning JSP, JSF and Tomcat) Capitolul 3 JSP Application Architectures DEZVOLTAREA APLICATIILOR WEB CURS

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

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

ddfffddd CS506 FINAL TERMS SOLVED BY MCQS GHAZAL FROM IEMS CAMPUS SMD CS506 Mcqs file solved by ghazal

ddfffddd CS506 FINAL TERMS SOLVED BY MCQS GHAZAL FROM IEMS CAMPUS SMD CS506 Mcqs file solved by ghazal ddfffddd CS506 FINAL TERMS SOLVED BY MCQS GHAZAL FROM IEMS CAMPUS SMD CS506 Mcqs file solved by ghazal Question:1 JSP action element is used to obtain a reference to an existing JavaBean object. usebean

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

Programming on the Web(CSC309F) Tutorial 9: JavaServlets && JDBC TA:Wael Abouelsaadat

Programming on the Web(CSC309F) Tutorial 9: JavaServlets && JDBC TA:Wael Abouelsaadat Programming on the Web(CSC309F) Tutorial 9: JavaServlets && JDBC TA:Wael Abouelsaadat WebSite: http://www.cs.toronto.edu/~wael Office-Hour: Friday 12:00-1:00 (SF2110) Email: wael@cs.toronto.edu 1 Using

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

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

Accessing EJB in Web applications

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

More information

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

Session 10. Form Dataset. Lecture Objectives

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

More information

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

Session 9. Data Sharing & Cookies. Reading & Reference. Reading. Reference http state management. Session 9 Data Sharing

Session 9. Data Sharing & Cookies. Reading & Reference. Reading. Reference http state management. Session 9 Data Sharing Session 9 Data Sharing & Cookies 1 Reading Reading & Reference Chapter 5, pages 185-204 Reference http state management www.ietf.org/rfc/rfc2109.txt?number=2109 2 3/1/2010 1 Lecture Objectives Understand

More information

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans University of New York, Tirana M.Sc. Computer Science Advanced Topics in Operating Systems Manual for Lab Practices Enterprise JavaBeans PART III A Web Banking Application with EJB and MySQL Development

More information

Learn Java/J2EE Basic to Advance level by Swadeep Mohanty

Learn Java/J2EE Basic to Advance level by Swadeep Mohanty Basics of Java Java - What, Where and Why? History and Features of Java Internals of Java Program Difference between JDK,JRE and JVM Internal Details of JVM Variable and Data Type OOPS Conecpts Advantage

More information

Connecting the RISC Client to non-javascriptinterfaces

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

More information

HTTP status codes. Setting status of an HTTPServletResponse

HTTP status codes. Setting status of an HTTPServletResponse HTTP status codes Setting status of an HTTPServletResponse What are HTTP status codes? The HTTP protocol standard includes three digit status codes to be included in the header of an HTTP response. There

More information

Lab session Google Application Engine - GAE. Navid Nikaein

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

More information

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

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

More information

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. Program to demonstrate applet life cycle

Chapter #1. Program to demonstrate applet life cycle Chapter #1. Program to demonstrate applet life cycle import java.applet.applet; import java.awt.*; public class LifeCycle extends Applet{ public void init(){ System.out.println(" init()"); public void

More information

Component Based Software Engineering

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

More information