- ServletConfig is an interface that allows initialization parameters to be passed to individual servlets. A ServletConfig object is created by the web container for each servlet.
- ServletContext is an interface that represents the entire servlet context or application. There is only one ServletContext per web application that can be accessed by all servlets. It provides global access to initialization parameters and application-level resources.
- Initialization parameters defined in web.xml using <context-param> are accessible to all servlets through the ServletContext, while parameters defined for individual servlets using <init-param> are only accessible through that servlet's ServletConfig.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
The document provides information on servlet fundamentals including definitions, applications, architecture, lifecycle, and development process. Some key points include:
- Servlets are Java programs that run on web servers and interact with clients via HTTP requests and responses. They provide dynamic content and process user input.
- Common servlet applications include search engines, e-commerce sites, and intranets.
- The servlet lifecycle includes initialization, processing requests, and destruction. Servlets remain loaded in memory between requests for improved performance over CGI.
- To develop a servlet, you create a class that implements the Servlet interface, define request handling methods, compile it, deploy it in a web container
The document discusses various PHP array functions including:
- Array functions like array_combine(), array_count_values(), array_diff() for comparing and merging arrays.
- Sorting arrays with asort(), arsort(), ksort(), krsort().
- Other functions like array_search(), array_sum(), array_rand() for searching, summing and random values.
- Modifying arrays with array_push(), array_pop(), array_shift() for adding/removing elements.
The document provides examples of using each array function in PHP code snippets.
The document discusses menu bars and menus in Java. It explains that a menu bar displays a list of top-level menu choices, with each choice associated with a drop-down menu. This is implemented using the MenuBar, Menu, and MenuItem classes. Menus can contain other menus and menu items. The document provides examples of how to construct menus and menu items, add them to the menu bar, and handle events when items are selected. It includes a full program example that creates a menu bar with file and edit menus for performing operations like cut, copy, paste, and for toggling debug and test modes.
This document discusses Java collections framework and various collection classes like ArrayList, LinkedList, HashSet, HashMap etc. It provides definitions and examples of commonly used collection interfaces like List, Set and Map. It explains key features of different collection classes like order, duplicates allowed, synchronization etc. Iterators and generic types are also covered with examples to iterate and create typed collection classes.
Functions allow programmers to organize code into reusable blocks. A function is defined using the def keyword and can accept parameters. The body of a function contains a set of statements that run when the function is called. Functions can return values and allow code to be reused, reducing errors and improving readability. Parameters allow information to be passed into functions, while return values allow functions to provide results.
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Lambda Expressions in Java” will introduce you to a new Java feature called Lambda Expressions. It will also talk about the functional interface in Java. Through this tutorial you will learn the following topics:
Java Lambda Expressions
Functional Interface
Lambda Parameters
Lambda as an Object
Lambda Value Capture
Method References as lambdas
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
A thread is an independent path of execution within a Java program. The Thread class in Java is used to create threads and control their behavior and execution. There are two main ways to create threads - by extending the Thread class or implementing the Runnable interface. The run() method contains the code for the thread's task and threads can be started using the start() method. Threads have different states like New, Runnable, Running, Waiting etc during their lifecycle.
The document discusses various event handling classes in Java including ActionEvent, KeyEvent, MouseEvent, MouseMotionEvent, FocusEvent, WindowEvent, and ItemEvent. It provides examples of how to use each event class by implementing the appropriate listener interface and defining event handling methods. Key points covered include common event handling terms like event, event source, and event listener. It also summarizes the typical methods provided by each event class.
The document provides information on servlet fundamentals including definitions, applications, architecture, lifecycle, and development process. Some key points include:
- Servlets are Java programs that run on web servers and interact with clients via HTTP requests and responses. They provide dynamic content and process user input.
- Common servlet applications include search engines, e-commerce sites, and intranets.
- The servlet lifecycle includes initialization, processing requests, and destruction. Servlets remain loaded in memory between requests for improved performance over CGI.
- To develop a servlet, you create a class that implements the Servlet interface, define request handling methods, compile it, deploy it in a web container
The document discusses various PHP array functions including:
- Array functions like array_combine(), array_count_values(), array_diff() for comparing and merging arrays.
- Sorting arrays with asort(), arsort(), ksort(), krsort().
- Other functions like array_search(), array_sum(), array_rand() for searching, summing and random values.
- Modifying arrays with array_push(), array_pop(), array_shift() for adding/removing elements.
The document provides examples of using each array function in PHP code snippets.
The document discusses menu bars and menus in Java. It explains that a menu bar displays a list of top-level menu choices, with each choice associated with a drop-down menu. This is implemented using the MenuBar, Menu, and MenuItem classes. Menus can contain other menus and menu items. The document provides examples of how to construct menus and menu items, add them to the menu bar, and handle events when items are selected. It includes a full program example that creates a menu bar with file and edit menus for performing operations like cut, copy, paste, and for toggling debug and test modes.
This document discusses Java collections framework and various collection classes like ArrayList, LinkedList, HashSet, HashMap etc. It provides definitions and examples of commonly used collection interfaces like List, Set and Map. It explains key features of different collection classes like order, duplicates allowed, synchronization etc. Iterators and generic types are also covered with examples to iterate and create typed collection classes.
Functions allow programmers to organize code into reusable blocks. A function is defined using the def keyword and can accept parameters. The body of a function contains a set of statements that run when the function is called. Functions can return values and allow code to be reused, reducing errors and improving readability. Parameters allow information to be passed into functions, while return values allow functions to provide results.
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Lambda Expressions in Java” will introduce you to a new Java feature called Lambda Expressions. It will also talk about the functional interface in Java. Through this tutorial you will learn the following topics:
Java Lambda Expressions
Functional Interface
Lambda Parameters
Lambda as an Object
Lambda Value Capture
Method References as lambdas
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
A thread is an independent path of execution within a Java program. The Thread class in Java is used to create threads and control their behavior and execution. There are two main ways to create threads - by extending the Thread class or implementing the Runnable interface. The run() method contains the code for the thread's task and threads can be started using the start() method. Threads have different states like New, Runnable, Running, Waiting etc during their lifecycle.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
Event handling involves responding to user actions like clicking buttons or typing text. Events are generated by sources like buttons or keyboards and handled by listeners that implement specific event listener interfaces. The listener is registered with the source to receive notifications when events occur, then processes the event by implementing callback methods defined in the listener interface. Common types of events include action events, item events, and mouse events.
This document provides an overview of Java Swing components. It defines Swing as a GUI toolkit built on top of AWT that provides platform-independent and lightweight components. It describes common Swing components like JButton, JTextField, JTextArea and their usage. It also compares AWT and Swing, explaining how Swing components are more powerful and support pluggable look and feel while AWT is platform-dependent. Examples are given to demonstrate creating and using Swing components like JButton, JTextField, JTextArea etc.
PHP provides built-in connectivity to many databases like MySQL, PostgreSQL, Oracle and more. To connect to a database in PHP, a connection is created using mysql_connect or mysql_pconnect, which may create a persistent connection. The high-level process involves connecting to the database, selecting a database, performing a SQL query, processing the results, and closing the connection. Key functions include mysql_query() to submit queries, mysql_fetch_array() to retrieve rows from the results, and mysql_close() to terminate the connection.
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
This document provides an overview of Applets and Java GUI programming. It discusses Applets, their life cycle, how to run Applets using AppletViewer and HTML, and classes used in Applet programming like Applet, Graphics, Color, Font, and AWT components. It also covers Swing components like JApplet, JComponent, JLabel, JTextField, JButton, and JRadioButton. Code examples and demonstrations are provided for many of the concepts discussed.
This document discusses the usage of command-line arguments in Java programs. Command-line arguments allow information to be passed into a program when it runs. In Java, command-line arguments are stored as strings in the string array passed to the main() method. An example program is provided that loops through the arguments and prints each one. Users are advised to convert arguments to the desired format using wrapper classes if needed. The key differences between command-line arguments in C and Java are also outlined.
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
Slides for a lightning talk on Java 8 lambda expressions I gave at the Near Infinity (www.nearinfinity.com) 2013 spring conference.
The associated sample code is on GitHub at https://github.com/sleberknight/java8-lambda-samples
Java applets allow Java programs to run in a web browser. Applets are downloaded and run similarly to web pages. When a web page containing an applet tag is loaded, the browser downloads the applet class file from the web server and executes it within the browser's context on the client host. Applets are subject to security restrictions that prevent them from accessing local files or making network connections except back to the host from which they were downloaded.
Android Intents allow communication between app components and sharing of data. An Intent specifies an action and can contain data and extras. There are explicit intents, which target a specific component, and implicit intents, which specify an action that may be handled by multiple apps. Components declare intent filters in the manifest to receive implicit intents matching the filter's action, data, and category. When an implicit intent is received, the system resolves matching components by comparing the intent to intent filters.
This chapter discusses dictionaries and sets in Python. It covers how to create, manipulate, and iterate over dictionaries and sets. Some key dictionary topics include adding and retrieving key-value pairs, checking for keys, and using dictionary methods. For sets, the chapter discusses set operations like union, intersection, difference and symmetric difference. It also covers serializing objects using the pickle module.
The document discusses Java applets and their core components. It explains that applets are Java programs that run within web browsers. Applets have a lifecycle of initialization, starting, painting, and stopping methods. The document provides details on how to write, compile, and embed a basic "Hello World" applet in an HTML file for testing. It also covers key classes like Graphics, Color, and Font used for applet graphics and UI.
Procedures functions structures in VB.Nettjunicornfx
This document discusses procedures, functions, and structures in Visual Basic .NET. It defines procedures as blocks of code that can be invoked from other parts of a program and optionally accept arguments. Functions are similar but return a value. Structures allow user-defined data types. The document provides examples and explains how to declare, define parameters for, and call procedures and functions. It also covers argument passing mechanisms, built-in math and string functions, and variable scope.
Fragments allow modularization of activities on larger screens like tablets. A fragment represents a behavior or UI portion and has its own lifecycle callbacks. Fragments can be placed in an activity layout via XML or added dynamically in code. Multiple fragments can be combined in a single activity to build a multi-pane UI. The activity lifecycle influences fragments, and fragments can be retained across configuration changes using setRetainInstance(true).
Operators in Java provide symbols that operate on arguments to produce results. The document discusses the different types of operators in Java including assignment, arithmetic, relational, logical, bitwise, and ternary operators. Examples are provided to demonstrate the usage of various operators like increment/decrement, arithmetic, relational, logical, bitwise, ternary, and instanceof operators in Java code.
The document discusses various window controls in C# .NET including message boxes, forms, buttons, labels, text boxes, check boxes, radio buttons, date/time pickers, progress bars, and dialog boxes. It provides details on how to use each control, its purpose, and relevant properties.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
This document provides an overview of Spring autowiring and annotation-based configuration. It discusses the different autowiring modes including byName, byType, and constructor. It also covers key annotations like @Autowired, @Qualifier, and @Required. The document explains how to enable annotation-based configuration in Spring and examples of using annotations on setter methods, constructors, and properties. Finally, it introduces Java-based Spring configuration using @Configuration and @Bean along with topics that will be covered in the next session on Spring AOP.
String objects are immutable in Java, so any operation that modifies a String value actually creates a new String object. The StringBuffer and StringBuilder classes provide mutable alternatives to String that have similar methods but do not create new objects with each modification. When a String literal value is used in code, it is stored in the String constant pool to promote reuse of these immutable objects.
The document discusses the Servlet Container Model and various servlet context and session related interfaces and classes in Java EE. It provides details on the ServletContext object and how it can be used to access initialization parameters, resources, attributes etc. It also describes the ServletContextListener interface used to listen to context initialization and destruction events, and the ServletContextAttributeListener used to listen to attribute changes. The document further discusses the HttpSession object and interfaces like HttpSessionListener and HttpSessionAttributeListener used to listen to session creation, destruction and attribute changes respectively.
The web.xml file is used to configure Java web applications and is located in the WEB-INF subdirectory. It defines mappings from servlet names to class files, global constants, and error pages. The file uses XML format and any errors will prevent the application from loading. It can contain welcome page properties to specify what page loads initially, and servlet mappings link URLs to servlet classes. Initial parameters store global values that can be accessed from servlet code.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
Event handling involves responding to user actions like clicking buttons or typing text. Events are generated by sources like buttons or keyboards and handled by listeners that implement specific event listener interfaces. The listener is registered with the source to receive notifications when events occur, then processes the event by implementing callback methods defined in the listener interface. Common types of events include action events, item events, and mouse events.
This document provides an overview of Java Swing components. It defines Swing as a GUI toolkit built on top of AWT that provides platform-independent and lightweight components. It describes common Swing components like JButton, JTextField, JTextArea and their usage. It also compares AWT and Swing, explaining how Swing components are more powerful and support pluggable look and feel while AWT is platform-dependent. Examples are given to demonstrate creating and using Swing components like JButton, JTextField, JTextArea etc.
PHP provides built-in connectivity to many databases like MySQL, PostgreSQL, Oracle and more. To connect to a database in PHP, a connection is created using mysql_connect or mysql_pconnect, which may create a persistent connection. The high-level process involves connecting to the database, selecting a database, performing a SQL query, processing the results, and closing the connection. Key functions include mysql_query() to submit queries, mysql_fetch_array() to retrieve rows from the results, and mysql_close() to terminate the connection.
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
This document provides an overview of Applets and Java GUI programming. It discusses Applets, their life cycle, how to run Applets using AppletViewer and HTML, and classes used in Applet programming like Applet, Graphics, Color, Font, and AWT components. It also covers Swing components like JApplet, JComponent, JLabel, JTextField, JButton, and JRadioButton. Code examples and demonstrations are provided for many of the concepts discussed.
This document discusses the usage of command-line arguments in Java programs. Command-line arguments allow information to be passed into a program when it runs. In Java, command-line arguments are stored as strings in the string array passed to the main() method. An example program is provided that loops through the arguments and prints each one. Users are advised to convert arguments to the desired format using wrapper classes if needed. The key differences between command-line arguments in C and Java are also outlined.
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
Slides for a lightning talk on Java 8 lambda expressions I gave at the Near Infinity (www.nearinfinity.com) 2013 spring conference.
The associated sample code is on GitHub at https://github.com/sleberknight/java8-lambda-samples
Java applets allow Java programs to run in a web browser. Applets are downloaded and run similarly to web pages. When a web page containing an applet tag is loaded, the browser downloads the applet class file from the web server and executes it within the browser's context on the client host. Applets are subject to security restrictions that prevent them from accessing local files or making network connections except back to the host from which they were downloaded.
Android Intents allow communication between app components and sharing of data. An Intent specifies an action and can contain data and extras. There are explicit intents, which target a specific component, and implicit intents, which specify an action that may be handled by multiple apps. Components declare intent filters in the manifest to receive implicit intents matching the filter's action, data, and category. When an implicit intent is received, the system resolves matching components by comparing the intent to intent filters.
This chapter discusses dictionaries and sets in Python. It covers how to create, manipulate, and iterate over dictionaries and sets. Some key dictionary topics include adding and retrieving key-value pairs, checking for keys, and using dictionary methods. For sets, the chapter discusses set operations like union, intersection, difference and symmetric difference. It also covers serializing objects using the pickle module.
The document discusses Java applets and their core components. It explains that applets are Java programs that run within web browsers. Applets have a lifecycle of initialization, starting, painting, and stopping methods. The document provides details on how to write, compile, and embed a basic "Hello World" applet in an HTML file for testing. It also covers key classes like Graphics, Color, and Font used for applet graphics and UI.
Procedures functions structures in VB.Nettjunicornfx
This document discusses procedures, functions, and structures in Visual Basic .NET. It defines procedures as blocks of code that can be invoked from other parts of a program and optionally accept arguments. Functions are similar but return a value. Structures allow user-defined data types. The document provides examples and explains how to declare, define parameters for, and call procedures and functions. It also covers argument passing mechanisms, built-in math and string functions, and variable scope.
Fragments allow modularization of activities on larger screens like tablets. A fragment represents a behavior or UI portion and has its own lifecycle callbacks. Fragments can be placed in an activity layout via XML or added dynamically in code. Multiple fragments can be combined in a single activity to build a multi-pane UI. The activity lifecycle influences fragments, and fragments can be retained across configuration changes using setRetainInstance(true).
Operators in Java provide symbols that operate on arguments to produce results. The document discusses the different types of operators in Java including assignment, arithmetic, relational, logical, bitwise, and ternary operators. Examples are provided to demonstrate the usage of various operators like increment/decrement, arithmetic, relational, logical, bitwise, ternary, and instanceof operators in Java code.
The document discusses various window controls in C# .NET including message boxes, forms, buttons, labels, text boxes, check boxes, radio buttons, date/time pickers, progress bars, and dialog boxes. It provides details on how to use each control, its purpose, and relevant properties.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
This document provides an overview of Spring autowiring and annotation-based configuration. It discusses the different autowiring modes including byName, byType, and constructor. It also covers key annotations like @Autowired, @Qualifier, and @Required. The document explains how to enable annotation-based configuration in Spring and examples of using annotations on setter methods, constructors, and properties. Finally, it introduces Java-based Spring configuration using @Configuration and @Bean along with topics that will be covered in the next session on Spring AOP.
String objects are immutable in Java, so any operation that modifies a String value actually creates a new String object. The StringBuffer and StringBuilder classes provide mutable alternatives to String that have similar methods but do not create new objects with each modification. When a String literal value is used in code, it is stored in the String constant pool to promote reuse of these immutable objects.
The document discusses the Servlet Container Model and various servlet context and session related interfaces and classes in Java EE. It provides details on the ServletContext object and how it can be used to access initialization parameters, resources, attributes etc. It also describes the ServletContextListener interface used to listen to context initialization and destruction events, and the ServletContextAttributeListener used to listen to attribute changes. The document further discusses the HttpSession object and interfaces like HttpSessionListener and HttpSessionAttributeListener used to listen to session creation, destruction and attribute changes respectively.
The web.xml file is used to configure Java web applications and is located in the WEB-INF subdirectory. It defines mappings from servlet names to class files, global constants, and error pages. The file uses XML format and any errors will prevent the application from loading. It can contain welcome page properties to specify what page loads initially, and servlet mappings link URLs to servlet classes. Initial parameters store global values that can be accessed from servlet code.
This document discusses several topics related to Java web application development using Spring and related technologies:
- It provides an example of using JPA annotations to map Java objects to a database using Hibernate and Spring.
- It describes how to configure dependencies and repositories in Maven to use Hibernate and related libraries.
- It explains concepts like Spring stereotype annotations, Spring MVC configuration in web.xml, and Spring configuration files.
- It also covers features of Spring 3.0, J2EE, design patterns, proxy server configuration, Log4j configuration, and differences between Struts and Spring.
This document provides an introduction to Java servlet technology. It discusses how servlets address limitations of CGI scripts by providing a portable way to generate dynamic web content from the server side using Java. Key topics covered include the servlet interface, lifecycle, and advantages over CGI such as improved performance and portability. Configuration and use of servlets within Eclipse and Tomcat are also explained.
The document discusses the key differences between ServletConfig and ServletContext in Java servlets. ServletConfig contains information for a single servlet and is used to access initialization parameters and the ServletContext. ServletContext contains information about the entire web application and can be used to store attributes accessible by all servlets. The document also provides an overview of the HttpServletRequest and HttpServletResponse objects, describing common methods for handling requests and responses. It explains how to define initialization parameters for servlets and contexts in the deployment descriptor and access them programmatically.
Implementing Listeners describes different types of listeners that can be used in Java web applications. Servlet context listeners are notified when the servlet context is initialized or destroyed. Session listeners are notified when sessions are created, invalidated, or timed out. Listeners are implemented by overriding specific methods and obtaining references to important objects like the servlet context or session. Listeners must also be declared in the application's configuration file.
The document provides a multiple choice quiz on Spring Framework concepts. It includes 10 multiple choice questions covering topics like Spring modules, bean scopes, annotation-driven configuration, Spring MVC, transactions, dependency injection, and Aspect Oriented Programming (AOP). It also includes 5 open-ended questions asking about Maven/Gradle, the web.xml file, the <annotation-driven/> tag, ViewResolvers in Spring, and descriptions of common annotations with examples.
This document provides an overview of key concepts for deploying web applications in Java, including:
1) Session tracking is provided by the HttpSession object returned by the getSession() method, which can store attributes.
2) A web application typically includes HTML, images, servlets, source code, libraries and other resources.
3) The server is responsible for mapping URLs to the location of a web application based on a specific prefix.
4) The standard structure for a web application includes the /WEB-INF directory for private resources and configuration files.
This is a step by step slides to study servlet, all the concepts which are required for a servlet are present in this ppt. The whole Servlet is divided into SESSIONS.
The document discusses ServletContext, ServletConfig, and HTTP session management in Java web applications. ServletContext represents application-level configuration and is shared across all servlets, while ServletConfig provides initialization parameters specific to an individual servlet. HTTP is stateless, so sessions are used to maintain state across multiple requests from the same user, either through cookies or URL rewriting if cookies are disabled. The session object allows attributes to be stored and retrieved to share data during a user's session.
A server is a computer program that provides services to other programs. The computer running the server program is called the server. Servers are often categorized by their purpose, such as web servers, application servers, proxy servers, and mail servers. A web server responds to HTTP requests to deliver web content and services. Servlets are Java programs that extend server functionality and respond dynamically to requests. Servlets provide advantages over older CGI programs like improved performance and scalability.
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 5...WebStackAcademy
Introduction
The server hands requests to a Container in which the servlet is deployed. The Container gives the servlet the HTTP request and response, and calls the servlet's method, such as doPost() or doGet(). It creates the HttpServletResponse and HttpServletRequest objects.
Process:
Container creates HttpServletRequest/HttpServletResponse objects
Container determines servlet based on URL-pattern, creates thread and calls service()
services calls doGet() or doPost()
servlet writes to response
service() completes, control returns to container
thread dies or returns to pool
The container provides:
web app communications support
lifecycle management
multithreading support
declarative security
support for JSPs
The document summarizes key concepts related to servlets including:
1) Servlets extend HttpServlet and implement init(), service(), and destroy() methods to handle requests and responses. Servlet instances are managed by the web container.
2) Servlet configuration allows initializing servlets through parameters defined in web.xml. The ServletConfig object provides access to these parameters.
3) Servlets communicate with clients via HttpServletRequest and HttpServletResponse objects, sending responses using getWriter() or getOutputStream(). Redirects use sendRedirect().
The document provides an introduction to the Spring MVC framework. It discusses the major components of Spring MVC including the DispatcherServlet, HandlerMappings, Controllers, Models, Views, and ViewResolvers. It explains the basic workflow of how a client request is processed in Spring MVC. Finally, it provides examples of implementing different types of controllers.
The document provides an introduction to using Servlets and JSPs to build dynamic web applications. It discusses the web application architecture and how requests are handled by the container. Servlets are Java classes that handle requests and responses, while JSPs simplify creating dynamic web pages by mixing HTML with Java code. The document outlines the servlet lifecycle and the differences between GET and POST requests. It also discusses how to retrieve and set request and response parameters, headers, and attributes to communicate between the client and server.
Java Servlet Programming under Ubuntu Linux by Tushar B KuteTushar B Kute
The document provides information on programming simple servlets under Ubuntu GNU/Linux. It discusses what can be built with servlets, the benefits of servlets over CGI, definitions of servlet containers and servlet architecture. It also covers the servlet lifecycle, request and response objects, and the steps to write a simple servlet class, compile it, deploy it on Tomcat, and run it.
Servlets are Java programs that extend the functionality of web servers. Servlets offer advantages over CGI like improved performance since they execute within the server's memory space rather than as separate processes. The lifecycle of a servlet involves initialization, processing requests, and destruction. Tomcat is a popular open source web server that supports servlets. It provides APIs and handles loading, executing, and unloading servlets in response to HTTP requests. Servlets can handle GET and POST requests, with GET parameters appearing in the URL and POST parameters in the request body.
Http Server Programming in JAVA - Handling http requests and responsesbharathiv53
This ppt contains HTML forms and CGI; HTTP; Servlet Programming; The Life Cycle of a
Servlet; Using Tomcat for Servlet Development; A simple Servlet;
deployment of simple servlets, web server (Java web server / Tomcat/ Web
logic) The Servlet API; The Javax.servlet Package; Reading Servlet
Parameter; The Javax.servlet.http package; Handling HTTP Requests and
Responses, HTTP GET and POST methods, Using Cookies; Session
Tracking
This document provides an overview of Java servlets. It defines servlets as Java programs that extend the capabilities of servers and respond to web requests. It compares servlets to CGI scripts, noting that servlets have better performance since they use threads instead of processes to handle requests. The document outlines the servlet lifecycle and architecture, how to create a servlet class, and key interfaces in the servlet API like Servlet, GenericServlet, and HttpServlet.
Integrating Servlets and JSP (The MVC Architecture)Amit Ranjan
This document discusses integrating servlets and JSP using the MVC architecture. It begins with an introduction to the MVC pattern, explaining the model, view, and controller components. It then covers advantages of MVC like separation of concerns and reusability. Next, it describes how MVC applies to servlets, with the servlet acting as controller and JSP as view. It explains how the web deployment descriptor (web.xml) provides initialization parameters and how servlets can forward requests to JSP. Finally, it discusses attributes, threading safety, and accessing initialization parameters from JSP.
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
Physiology and chemistry of skin and pigmentation, hairs, scalp, lips and nail, Cleansing cream, Lotions, Face powders, Face packs, Lipsticks, Bath products, soaps and baby product,
Preparation and standardization of the following : Tonic, Bleaches, Dentifrices and Mouth washes & Tooth Pastes, Cosmetics for Nails.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
How to Fix the Import Error in the Odoo 17Celine George
An import error occurs when a program fails to import a module or library, disrupting its execution. In languages like Python, this issue arises when the specified module cannot be found or accessed, hindering the program's functionality. Resolving import errors is crucial for maintaining smooth software operation and uninterrupted development processes.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
1. ServletConfig & ServletContext :-
ß Suppose let us here we have multiple servlet. Here there are three servlet A, B, C
under classes’ folder. If you want to give any input to all the servlet A, B, C
servlet.
ß I want to pass the same connection object to AServlet , BServlet, CServlet.
Suppose I have a JDBC connection object, I want to give that object to AServlet,
BServlet, CServlet.
ß I have only one resource I want to share that resource to all servlet then what
should will do- it makes as.
ASHUTOSH TRIVEDI
Email:trivedi.ashutosh2013@gmail.com
MNO—9580074408
Read ServletConfig & ServletContext by ASHUTOSH
2. ß I have a single resource if I want to share same resource to all the user then
resource need to become to public resource.
ß An object of ServletContext is created by the web container at time of deploying
the project.
ß This object can be used to get configuration information from web.xml file.
ß There is only one ServletContext object per web application.
ß It is one per web application. So it is called as the global memory of web
application.
ß ServletContext object means it is the object of a java class (container supplier)
implementing javax.servlet.ServletConext interface.
ß Servlet container creates this object either during deployment of the web
application or during server start-up.
ß Servlet container destroys this object automatically when web application is
undeployed or reloaded or stopped or when server is stopped/ re-started.
¸ An object of ServletContext is created by the web container at the time of deploying
the project.
¸ There is only one ServletContext object per web application.
¸ This Servletcontext object can be used to get configuration information from
web.xml file. If any information is shared to many object, it is better to provide it
from the web.xml file using the <context-param> element.
3. ¸ Easy to maintain if any information is shared to all the servlet it is better to make it
available for all the servlet. We provide this information from the web.xml, so if the
information is changer we don't need to modify the servlet. Thus if removes
maintenance problem.
¸ Every web Application runs in a separate context which isolates it from another
application running in the same server.
¸ Defines a set of methods that a servlet uses to communicate with its servlet container,
for example to get the MIME type of a file dispatch requests or write to a log file.
4. ¸ For every Servlet, web container will create one ServletConfig object to maintain
Servlet level initialization parameter. By using this object Servlet can get its
configuration information.
¸ Similarly for every web-application webcontainer creates one ServletContext object
to maintain application level configuration information.
¸ Servlet can get application level configuration information through this context
object only.
¸ ServletConfig per Servlet, whereas ServletContext per Web-application.
¸ If initialization parameters are common for all Servlets then it is not recommended to
declare those parameters at Servlet level , we have to declare such type of parameters
at application -level by using < context-param >
<web-app>
<context-param>
<param-name>username</param-name>
<param-value>scott</param-value>
</context-param>
</web-app>
¸ We can declare any number of context parameters but one < context-param > for each
Servlet.
¸ < context-param > is the direct child tag of <web-app > & hence we can declare
anywhere within <web-app>
¸ The context initialization parameters are available throughout the web-application
anywhere.
¸ If we want to use same init-parameters then we can declare at context-level as
<context-param>
<param-name>username</param-name>
<param-value>scott</param-value>
</context-param>
5. ¸ Within the Servlet we can access these context initialization parameters by using
ServletContext object.
How to Get ServletContext Object into Our Servlet Class
∑ In servlet programming we have 3 approaches for obtaining an object of
ServletContext interface.
Way 1.
Syntax-
//We can get ServletContext object from ServletConfig
ServletConfig conf = getServletConfig();
ServletContext context = conf.getServletContext();
∑ First obtain an object of ServletConfig interface ServletConfig interface contain
direct method to get Context object, getServletContext();.
Way 2.
∑ Direct approach, just call getServletContext() method available in GenericServlet
[pre-defined]. In general we are extending our class with HttpServlet, but we know
HttpServlet is the sub class of GenericServlet.
Syntax-
//Another convenient way to get ServletContext object
ServletContext context = getServletContext();
Way 3.
∑ We can get the object of ServletContext by making use of HttpServletRequest
object, we have direct method in HttpServletRequest interface.
Syntax:-
public class MyJava extends HttpServlet
{
public void doGet/doPost(HttpServletRequest req,-)
{
ServletContext ctx = req.getServletContext();
}
}
6. Commonly used methods of ServletContext interface
There is given some commonly used methods of ServletContext interface.
1. public String getInitParameter(String name):Returns the parameter value for the
specified parameter name.
2. public Enumeration getInitParameterNames():Returns the names of the context's
initialization parameters.
3. public void setAttribute(String name,Object object):sets the given object in the
application scope.
4. public Object getAttribute(String name):Returns the attribute for the specified
name.
5. public Enumeration getInitParameterNames():Returns the names of the context's
initialization parameters as an Enumeration of String objects.
6. public void removeAttribute(String name):Removes the attribute with the given
name from the servlet context.
Syntax to provide the initialization parameter in Context scope
∑ The context-param element, subelement of web-app, is used to define the initialization
parameter in the application scope. The param-name and param-value are the sub-
elements of the context-param. The param-name element defines parameter name and
and param-value defines its value.
web.xml
<web-app>
....
<context-param>
<param-name>parametername</param-name>
<param-value>parametervalue</param-value>
</context-param>
...
</web-app>
7. Example of ServletContext to get the initialization parameter
∑ In this example, we are getting the initialization parameter from the web.xml file and
printing the value of the initialization parameter. Notice that the object of ServletContext
represents the application scope. So if we change the value of the parameter from the
web.xml file, all the servlet classes will get the changed value. So we don't need to
modify the servlet. So it is better to have the common information for most of the
servlets in the web.xml file by context-param element. Let's see the simple example:
web.xml
<web-app>
....
<display-name> HelloGenericServlet </display-name>
<description>
This is a simple web application with a source code .
</description>
<context-param>
<param-name>drivername</param-name>
<param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
</context-param>
<context-param>
<param-name>username</param-name>
<param-value>system</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>oracle</param-value>
</context-param>
<servlet>
<servlet-name> context </servlet-name>
<servlet-class> ServletContextDemoServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> context</servlet-name>
<url-pattern> /context </url-pattern>
</servlet-mapping>
...
8. import java.io.*;
import javax.servlet.*;
public class ServletContextDemoServlet implements HttpServlet{
private static final long serialVersionUID=11;
ServletConfig config=null;
public void init() throws ServletException
{
System.out.println("-----------------------------------------------------------------");
System.out.println("init method is called in "+ this.getClass().getName());
System.out.println("-----------------------------------------------------------------");
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
ServletContext context=getServletContext();
out.print("<b> Read specific InitParam using context.getInitParameter(String paramName
</b> <br> <br>");
String driverName=context.getInitParameter("drivername");
out.print(driverName+"<br><br>")
out.print("<b> Read All InitParameters using getInitParameterNames() method </b> <br>");
Enumeration<String> initParamNamesEnum=context.getInitParameterNames();
String paramName="";
while (initParamNamesEnum.hasMoreElements())
{
paramName = initParamNamesEnum.nextElement();
paramValue= context.getInitParameter(paramName);
out.print("<br> "+ paramName + ": " + paramValue);
}
System.out.println("-----------------------------------------------------------------");
System.out.println("sevice method has been called ");
System.out.println("-----------------------------------------------------------------");
res.setContentType("text/html");
9. PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print ("<br>");
out.print("</body></html>");
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException
{
doGet(request, response)
}
public void destroy()
{
System.out.println("-----------------------------------------------------------------");
System.out.println("destroy method has been called and servlet is destroyed ");
System.out.println("-----------------------------------------------------------------");
}
}
// Index.html
<html>
<head><title>Context test</title>
<body>
<li><a href="context">Context Test</a></li>
</body>
</html>
10. ServletConfig (one per SERVLET):
¸ ServletConfig is an interface which is present in javax.servlet.* package.
¸ The purpose of ServletConfig is to pass some initial parameter values, technical
information (driver name, database name, data source name, etc.) to a servlet.
¸ An object of ServletConfig will be created one per servlet.
¸ An object of ServletConfig will be created by the server at the time of executing
public void init (ServletConfig) method.
¸ An object of ServletConfig cannot be accessed in the default constructor of a Servlet
class.Since, at the time of executing default constructor ServletConfig object does not
exist.
¸ By default ServletConfig object can be accessed with in init () method only but not in
doGet and doPost. In order to use, in the entire servlet preserve the reference of
ServletConfig into another variable and declare this variable into a Servlet class as a
data member of ServletConfig.
11. v When we want to give some global data to a servlet we must obtain an object of
ServletConfig.
v web.xml entries for ServletConfig
<servlet>
………….
<init-param>
<param-name>Name of the parameter</param-name>
<param-value>Value of the parameter</param-value>
</init-param>
………….
</servlet>
For example:
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>serv1</servlet-class>
<init-param>
<param-name>v1</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param name>v2</param name>
12. <param-value>20</param-value>
</init-param>
</servlet>
ÿ The data which is available in ServletConfig object is in the form of (key, vlaue)
OBTAINING an object of ServletConfig:
v An object of ServletConfig can be obtained in two ways, they are by calling
getServletConfig() method and by calling init (ServletConfig).
v Within the Servlet we can get its Config object as follows.
ServletConfig config=getServletConfig();
By calling getServletConfig () method:
v getServletConfig() is the method which is available in javax.servlet.Servlet interface.
This method is further inherited and defined into a class called
javax.servlet.GenericServlet and that method is further inherited into another predefined
class called javax.servlet.http.HttpServlet and it can be inherited into our own servlet
class.
For example:
public class serv1 extends HttpServlet
{
public void doGet (HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
…………
…………
ServletConfig config=this.getServletConfig ();
…………
…………
}
}
13. In the above example an object config contains (key, value) pair data of web.xml file which
are written under <init-param> tag of <servlet> tag.
v By calling init (ServletConfig):
For example:
public class serv2 extends HttpServlet
{
ServletConfig sc;
public void init (ServletConfig sc)
{
Super.init (sc); // used for calling init (ServletConfig) method of HttpServlet
this.sc=sc; // ServletConfig object sc is referenced
}
…………
…………
};
RETRIEVING DATA from ServletConfig interface object:
∑ In order to get the data from ServletConfig interface object we must use the following
methods:
public String getInitParameter (String); ____________ 1
public Enumeration getInitParameterNames (); ________ 2
v Method-1 is used for obtaining the parameter value by passing parameter name
Key Value
V1 10
V2 20
V3 30
Parameter-name Parameter-value
14. String val1=config.getInitParameter (“v1”);
String val2=config.getInitParameter (“v2”);
String val3=config.getInitParameter (“v3”);
vMethod-2 is used for obtaining all parameter names and their corresponding parameter
values.
For example:
Enumeration en=config.getInitParameterNames ();
while (en.hasMoreElements ())
{
Object obj=en.nextElement ();
String pname= (String) obj;
String pvalue=config.getInitParameter (pname);
out.println (pvalue+” is the value of ”+pname);
}
Serv1.java:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Serv1 extends HttpServlet
{
public void doGet (HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
res.setContentType ("text/html");
PrintWriter pw=res.getWriter ();
ServletConfig config=getServletConfig ();
String val1=config.getInitParameter ("v1");
String val2=config.getInitParameter ("v2");
String val3=config.getInitParameter ("v3");
String val4=config.getInitParameter ("v4");
pw.println ("<h3> Value of v1 is "+val1+"</h3>");
pw.println ("<h3> Value of v2 is "+val2+"</h3>");
pw.println ("<h3> Value of v3 is "+val3+"</h3>");
pw.println ("<h3> Value of v4 is "+val4+"</h3>");
}
};
15. Serv2.java:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Serv2 extends HttpServlet
{
public void doGet (HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
res.setContentType ("text/html");
PrintWriter pw=res.getWriter ();
ServletConfig config=getServletConfig ();
Enumeration en=config.getInitParameterNames ();
while (en.hasMoreElements ())
{
Object obj=en.nextElement ();
String pname= (String) obj;
String pvalue=config.getInitParameter (pname);
pw.println ("</h2>"+pvalue+" is the value of "+pname+"</h2>");
}
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>Serv1</servlet-class>
<init-param>
<param-name>v1</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>v2</param-name>
<param-value>20</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>pqr</servlet-name>
<servlet-class>Serv2</servlet-class>
18. Property Servlet init-param Servlet context-param
1. declaration
By using init-param with in
servlet.
<servlet>
<init-param>
<param-name>
<param-value>
</init-param>
</servlet>
By using init-param with in
web-app.
<servlet>
<context-param>
<param-name>
<param-value>
</context-param>
</servlet>
2. Servlet code to
Access the parameter
String
value=getInitParameter("pname")
;
(or)
String value=getServletConfig(
).getInitParameter("pname");
String
value=getServletContext(
).getInitParameter("pname")
;
(or)
String
value=getServletConfig(
).getServletContext(
).getInitParameter("pname")
;
3. Availability(Scope)
Available only for a particular
Servlet in which <init-param> is
declared.
Available for all Servlet's &
Jsp's within the web-
application.