ServletConfig Interface

Similar documents
Advanced Internet Technology Lab # 4 Servlets

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

AJP. CHAPTER 5: SERVLET -20 marks

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

Servlets by Example. Joe Howse 7 June 2011

Servlet Basics. Agenda

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

CIS 3952 [Part 2] Java Servlets and JSP tutorial

Complimentary material for the book Software Engineering in the Agile World

JSP. Common patterns

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

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

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

Author - Ashfaque Ahmed

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

Web based Applications, Tomcat and Servlets - Lab 3 -

Servlet Fudamentals. Celsina Bignoli

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

CreateServlet.java

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

Introduction to Servlets. After which you will doget it

Université Antonine - Baabda

Servlets Pearson Education, Inc. All rights reserved.

J2ME With Database Connection Program

Getting started with Winstone. Minimal servlet container

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

Develop an Enterprise Java Bean for Banking Operations

Stateless -Session Bean

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

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

Advanced Web Technology

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

Unit 4 - Servlet. Servlet. Advantage of Servlet

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

Java Servlets. Preparing your System

Accessing EJB in Web applications

JavaServer Pages (JSP)

Unit-4: Servlet Sessions:

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

Scheme G Sample Question Paper Unit Test 2

CSC309: Introduction to Web Programming. Lecture 10

UNIT-V. Web Servers: Tomcat Server Installation:

XmlEngine user s manual

Servlet 5.1 JDBC 5.2 JDBC

Module 4: SERVLET and JSP

Lecture Notes On J2EE

HTTP status codes. Setting status of an HTTPServletResponse

CS433 Technology Overview

Session 8. Introduction to Servlets. Semester Project

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang

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

Introduction to Web applications with Java Technology 3- Servlets

SWE642 Oct. 22, 2003

Handout 31 Web Design & Development

Appendix: Assorted Sweets

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

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

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

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

SERVLET AND JSP FILTERS

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

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

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

Welcome to Ruby. Yehuda Katz. Engine Yard

Lab session Google Application Engine - GAE. Navid Nikaein

The Servlet Life Cycle

Introduction to Server-Side Technologies

Penetration: from application down to OS

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

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

Servlets Basic Operations

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

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

Server Side Internet Programming

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

Session 9. Introduction to Servlets. Lecture Objectives

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

Servlet and JSP Review

Questions and Answers

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

Backend. (Very) Simple server examples

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

Servlets and JSP (Java Server Pages)

An implementation of Tree Panel component in EXT JS 4.0

Preview from Notesale.co.uk Page 6 of 132

Copyright 2005, by Object Computing, Inc. (OCI). All rights reserved. Database to Web

DiagServer.java 1/2 examples7/

CHAPTER 2: A FAST INTRODUCTION TO BASIC SERVLET PROGRAMMING

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

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

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

OpenClinica: Towards Database Abstraction, Part 1

Algorithmic Verification of Procedural Programs in the Presence of Code Variability

Using Java servlets to generate dynamic WAP content

SDN Community Contribution

Java Server Pages JSP

Introdução a Servlets

Integrate JPEGCAM with WaveMaker

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Transcription:

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 web.xml file. If the configuration information is modified from the web.xml file, we don't need to change the servlet. So it is easier to manage the web application if any specific content is modified from time to time. Advantage of ServletConfig The core advantage of ServletConfig is that you don't need to edit the servlet file if information is modified from the web.xml file. Methods of ServletConfig interface 1. public String getinitparameter(string name):returns the parameter value for the specified parameter name. 2. public Enumeration getinitparameternames():returns an enumeration of all the initialization parameter names. 3. public String getservletname():returns the name of the servlet. 4. public ServletContext getservletcontext():returns an object of ServletContext. How to get the object of ServletConfig 1. getservletconfig() method of Servlet interface returns the object of ServletConfig. Syntax of getservletconfig() method 1. public ServletConfig getservletconfig();

Example of getservletconfig() method 1. ServletConfig config=getservletconfig(); 2. //Now we can call the methods of ServletConfig interface Syntax to provide the initialization parameter for a servlet The init-param sub-element of servlet is used to specify the initialization parameter for a servlet.... parametername parametervalue... Example of ServletConfig to get initialization parameter In this example, we are getting the one initialization parameter from the web.xml file and printing this information in the servlet..java import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; public class extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); ServletConfig config=getservletconfig(); String driver=config.getinitparameter("driver"); out.print("driver is: "+driver); out.close(); web.xml driver sun.jdbc.odbc.jdbcodbcdriver /servlet1

Example of ServletConfig to get all the initialization parameters In this example, we are getting all the initialization parameter from the web.xml file and printing this information in the servlet..java import java.io.ioexception; import java.io.printwriter; import java.util.enumeration; import javax.servlet.servletconfig; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;public class extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); ServletConfig config=getservletconfig(); Enumeration e=config.getinitparameternames(); String str=""; while(e.hasmoreelements()){ str=e.nextelement(); out.print(" Name: "+str); out.print(" value: "+config.getinitparameter(str)); out.close(); web.xml

Powered by TCPDF (www.tcpdf.org) World4Engineers username system password oracle /servlet1