The document discusses Java Database Connectivity (JDBC) and how it allows Java programs to connect to databases. It describes the four types of JDBC drivers, the core JDBC interfaces like Driver, Connection, and Statement, and how to use JDBC to perform CRUD operations. The key interfaces allow establishing a database connection and executing SQL statements to retrieve and manipulate data.
The document discusses Java event handling and the delegation event model. It describes key concepts like events, sources that generate events, and listeners that handle events. It provides examples of registering components as listeners and implementing listener interfaces. The delegation event model joins sources, listeners, and events by notifying listeners when sources generate events.
The document discusses method overloading and overriding in Java. It defines method overloading as having multiple methods with the same name but different parameters, while overriding involves subclasses providing specific implementations of methods in the parent class. It provides examples of overloading methods by changing parameters and data types, and explains why overriding is not possible by only changing the return type due to ambiguity. The use of the super keyword to refer to parent class members is also explained.
This document discusses working with frames in Java. It explains the constructors of the Frame class, including Frame() and Frame(String title). It then describes several common methods for working with frames, such as setSize() to set dimensions, setVisible() to show or hide the frame, and setTitle() to set the title. It also covers closing a frame by calling setVisible(false) and implementing the windowClosing() method.
The document discusses exception handling in Java. It defines exceptions as runtime errors that occur during program execution. It describes different types of exceptions like checked exceptions and unchecked exceptions. It explains how to use try, catch, throw, throws and finally keywords to handle exceptions. The try block contains code that might throw exceptions. The catch block catches and handles specific exceptions. The finally block contains cleanup code that always executes regardless of exceptions. The document provides examples of exception handling code in Java.
Java applications cannot directly communicate with a database to submit data and retrieve the results of queries.
This is because a database can interpret only SQL statements and not Java language statements.
For this reason, you need a mechanism to translate Java statements into SQL statements.
The JDBC architecture provides the mechanism for this kind of translation.
The JDBC architecture can be classified into two layers :
JDBC application layer.
JDBC driver layer.
JDBC application layer : Signifies a Java application that uses the JDBC API to interact with the JDBC drivers. A JDBC driver is software that a Java application uses to access a database. The JDBC driver manager of JDBC API connects the Java application to the driver.
JDBC driver layer : Acts as an interface between a Java applications and a database. This layer contains a driver , such as a SQL server driver or an Oracle driver , which enables connectivity to a database.
A driver sends the request of a Java application to the database. After processing the request, the database sends the response back to the driver. The driver translates and sends the response to the JDBC API. The JDBC API forwards it to the Java application.
Servlets are Java programs that run on a web or application server and act as a middle layer between a request coming from a web browser or other HTTP client and databases or applications on the HTTP server. Servlets receive HTTP requests and return HTTP responses by accepting request parameters, generating dynamic content, accessing databases, and performing network communications using Java. Servlets are commonly used to add dynamic content to web pages and to access backend databases. The lifecycle of a servlet involves initialization, servicing client requests, and destruction. Common servlet APIs include classes for handling HTTP requests and responses, reading request parameters, using cookies and sessions.
The document provides an introduction to Java servlets and JavaServer Pages (JSP). It discusses servlet lifecycles and interfaces like ServletRequest and RequestDispatcher. It covers session tracking techniques including cookies, hidden form fields, and URL rewriting. It also mentions servlet events and listeners.
Threads allow multiple tasks to run concurrently within a single Java program. A thread represents a separate path of execution and threads can be used to improve performance. There are two main ways to create threads: by extending the Thread class or implementing the Runnable interface. Threads transition between different states like new, runnable, running, blocked, and terminated. Synchronization is needed to prevent race conditions when multiple threads access shared resources simultaneously. Deadlocks can occur when threads wait for each other in a circular manner.
Socket programming in Java allows applications to communicate over the internet. Sockets are endpoints for communication that are identified by an IP address and port number. A socket connection is established between a client and server socket. The server creates a welcoming socket to accept client connection requests, then a separate connection socket to communicate with that client. Data can be sent bidirectionally over the connected sockets as input/output streams. UDP uses datagram sockets without a connection, requiring the explicit destination address on each message.
The presentation given at MSBTE sponsored content updating program on 'Advanced Java Programming' for Diploma Engineering teachers of Maharashtra. Venue: Guru Gobind Singh Polytechnic, Nashik
Date: 22/12/2010
Session: Java Network Programming
Servlet is java class which extends the functionality of web server by dynamically generating web pages.
Servlet technology is used to create Dynamic web application. Servlet technology is robust and scalable. init() and service() methods are more important in life cycle of a servlet. doGet() and doPost() are methods used under service() method.
Java Server Pages (JSP) allow Java code to be embedded within HTML pages to create dynamic web content. JSP pages are translated into servlets by the web server. This involves compiling the JSP page into a Java servlet class that generates the HTML response. The servlet handles each request by executing the jspService() method and produces dynamic content which is returned to the client browser.
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 the Model-View-Controller (MVC) design pattern. MVC separates an application's logic into three main components: the model, the view, and the controller. The model manages the application's data and logic, the view displays the data to the user, and the controller interprets user input and updates the model. MVC improves separation of concerns and makes applications more modular, extensible, and testable. It is commonly used for web applications, where the server handles the model and controller logic while the client handles the view.
This document discusses servlets, which are Java programs that extend the capabilities of web servers to enable dynamic web content. Servlets run on the server-side and generate HTML responses to HTTP requests from clients. The document covers the basics of servlets, how they interface with web servers, their lifecycle including initialization and destruction, advantages over previous technologies like CGI, and implementation details.
This document provides an overview of Java applets, including:
- Applets are small Java programs that can be transported over the network and embedded in HTML pages.
- The main types of Java programs are standalone programs and web-based programs like applets.
- Applets differ from applications in that they have a predefined lifecycle and are embedded in web pages rather than running independently.
- The Applet class is the superclass for all applets and defines methods corresponding to the applet lifecycle stages like init(), start(), paint(), stop(), and destroy().
- Common methods for applets include drawString() for output, setBackground()/getBackground() for colors, and showStatus() to display in
This document provides an overview of Spring MVC including:
- Spring MVC is a web framework built on the Servlet API that uses the MVC pattern. It features a DispatcherServlet that handles requests and delegates to controllers.
- The request processing workflow in Spring MVC involves the DispatcherServlet dispatching tasks to controllers, which interact with services and return a view name. The view is then rendered using a ViewResolver.
- Spring MVC applications use a WebApplicationContext containing web-related beans like controllers and mappings, which can override beans in the root context. Configuration can be done via XML or Java-based approaches. Important annotations map requests and bind parameters.
The document describes the Model-View-Controller (MVC) software architectural pattern. MVC separates an application into three main components: the model, the view, and the controller. The model manages the application's data and business logic. The view displays the model's information. The controller interprets inputs from the user and updates the model and/or view accordingly. This separation of concerns makes the application modular, reusable, and maintainable.
This document provides an overview of Java input/output (I/O) concepts including reading from and writing to the console, files, and streams. It discusses different I/O stream classes like PrintStream, InputStream, FileReader, FileWriter, BufferedReader, and how to read/write characters, bytes and objects in Java. The document also introduces new I/O features in Java 7 like try-with-resources for automatic resource management.
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.
This document provides an introduction and overview of AJAX (Asynchronous JavaScript and XML). It defines AJAX as a methodology for building interactive web applications using a combination of technologies including XHTML, CSS, DOM, XML, JavaScript, and HTTP. The document outlines the history of AJAX and how it enables asynchronous communication with servers. It also discusses key AJAX components, the process cycle, advantages like improved interactivity, and disadvantages like compatibility issues. Examples of AJAX in use are given, like Google Suggest, and the XMLHttpRequest object is explained as the enabling technology behind asynchronous HTTP requests in AJAX applications.
Packages in Java are used to organize classes and avoid naming conflicts. A package contains related classes and groups them by functionality. Packages can be stored in JAR files. Fully qualified class names include the package name to uniquely identify classes. There are Java API packages and user-defined packages. The Java API packages contain commonly used classes organized by functionality. Packages are specified using dot notation and control access to classes.
This document discusses interfaces in Java. It defines an interface as a blueprint of a class that defines static constants and abstract methods. Interfaces are used to achieve abstraction and multiple inheritance in Java. They represent an "is-a" relationship. There are three main reasons to use interfaces - for abstraction, to support multiple inheritance functionality, and to achieve loose coupling. The document provides examples of interfaces, such as a Printable interface and implementations in different classes. It also demonstrates multiple inheritance using interfaces and interface inheritance.
The document discusses different layout managers in Java including BorderLayout, GridLayout, FlowLayout, CardLayout, and BoxLayout. BorderLayout arranges components in five regions (north, south, east, west, center) with one component per region. GridLayout arranges components in a rectangular grid with the same number of components per row. FlowLayout arranges components in a line, one after another. CardLayout displays one component at a time, treating each like a card. BoxLayout arranges components along an axis.
The document discusses XML namespaces and XML schemas. It provides examples of using namespaces to differentiate between similarly named elements, such as <highschool:subject> and <medicine:subject>. It also compares defining an XML document using a DTD versus using an XML schema, and provides a sample schema for defining book information. Key differences between "ref" and "type" attributes in schemas are explained using an employee example.
Threads allow multiple tasks to run concurrently within a single Java program. A thread represents a separate path of execution and threads can be used to improve performance. There are two main ways to create threads: by extending the Thread class or implementing the Runnable interface. Threads transition between different states like new, runnable, running, blocked, and terminated. Synchronization is needed to prevent race conditions when multiple threads access shared resources simultaneously. Deadlocks can occur when threads wait for each other in a circular manner.
Socket programming in Java allows applications to communicate over the internet. Sockets are endpoints for communication that are identified by an IP address and port number. A socket connection is established between a client and server socket. The server creates a welcoming socket to accept client connection requests, then a separate connection socket to communicate with that client. Data can be sent bidirectionally over the connected sockets as input/output streams. UDP uses datagram sockets without a connection, requiring the explicit destination address on each message.
The presentation given at MSBTE sponsored content updating program on 'Advanced Java Programming' for Diploma Engineering teachers of Maharashtra. Venue: Guru Gobind Singh Polytechnic, Nashik
Date: 22/12/2010
Session: Java Network Programming
Servlet is java class which extends the functionality of web server by dynamically generating web pages.
Servlet technology is used to create Dynamic web application. Servlet technology is robust and scalable. init() and service() methods are more important in life cycle of a servlet. doGet() and doPost() are methods used under service() method.
Java Server Pages (JSP) allow Java code to be embedded within HTML pages to create dynamic web content. JSP pages are translated into servlets by the web server. This involves compiling the JSP page into a Java servlet class that generates the HTML response. The servlet handles each request by executing the jspService() method and produces dynamic content which is returned to the client browser.
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 the Model-View-Controller (MVC) design pattern. MVC separates an application's logic into three main components: the model, the view, and the controller. The model manages the application's data and logic, the view displays the data to the user, and the controller interprets user input and updates the model. MVC improves separation of concerns and makes applications more modular, extensible, and testable. It is commonly used for web applications, where the server handles the model and controller logic while the client handles the view.
This document discusses servlets, which are Java programs that extend the capabilities of web servers to enable dynamic web content. Servlets run on the server-side and generate HTML responses to HTTP requests from clients. The document covers the basics of servlets, how they interface with web servers, their lifecycle including initialization and destruction, advantages over previous technologies like CGI, and implementation details.
This document provides an overview of Java applets, including:
- Applets are small Java programs that can be transported over the network and embedded in HTML pages.
- The main types of Java programs are standalone programs and web-based programs like applets.
- Applets differ from applications in that they have a predefined lifecycle and are embedded in web pages rather than running independently.
- The Applet class is the superclass for all applets and defines methods corresponding to the applet lifecycle stages like init(), start(), paint(), stop(), and destroy().
- Common methods for applets include drawString() for output, setBackground()/getBackground() for colors, and showStatus() to display in
This document provides an overview of Spring MVC including:
- Spring MVC is a web framework built on the Servlet API that uses the MVC pattern. It features a DispatcherServlet that handles requests and delegates to controllers.
- The request processing workflow in Spring MVC involves the DispatcherServlet dispatching tasks to controllers, which interact with services and return a view name. The view is then rendered using a ViewResolver.
- Spring MVC applications use a WebApplicationContext containing web-related beans like controllers and mappings, which can override beans in the root context. Configuration can be done via XML or Java-based approaches. Important annotations map requests and bind parameters.
The document describes the Model-View-Controller (MVC) software architectural pattern. MVC separates an application into three main components: the model, the view, and the controller. The model manages the application's data and business logic. The view displays the model's information. The controller interprets inputs from the user and updates the model and/or view accordingly. This separation of concerns makes the application modular, reusable, and maintainable.
This document provides an overview of Java input/output (I/O) concepts including reading from and writing to the console, files, and streams. It discusses different I/O stream classes like PrintStream, InputStream, FileReader, FileWriter, BufferedReader, and how to read/write characters, bytes and objects in Java. The document also introduces new I/O features in Java 7 like try-with-resources for automatic resource management.
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.
This document provides an introduction and overview of AJAX (Asynchronous JavaScript and XML). It defines AJAX as a methodology for building interactive web applications using a combination of technologies including XHTML, CSS, DOM, XML, JavaScript, and HTTP. The document outlines the history of AJAX and how it enables asynchronous communication with servers. It also discusses key AJAX components, the process cycle, advantages like improved interactivity, and disadvantages like compatibility issues. Examples of AJAX in use are given, like Google Suggest, and the XMLHttpRequest object is explained as the enabling technology behind asynchronous HTTP requests in AJAX applications.
Packages in Java are used to organize classes and avoid naming conflicts. A package contains related classes and groups them by functionality. Packages can be stored in JAR files. Fully qualified class names include the package name to uniquely identify classes. There are Java API packages and user-defined packages. The Java API packages contain commonly used classes organized by functionality. Packages are specified using dot notation and control access to classes.
This document discusses interfaces in Java. It defines an interface as a blueprint of a class that defines static constants and abstract methods. Interfaces are used to achieve abstraction and multiple inheritance in Java. They represent an "is-a" relationship. There are three main reasons to use interfaces - for abstraction, to support multiple inheritance functionality, and to achieve loose coupling. The document provides examples of interfaces, such as a Printable interface and implementations in different classes. It also demonstrates multiple inheritance using interfaces and interface inheritance.
The document discusses different layout managers in Java including BorderLayout, GridLayout, FlowLayout, CardLayout, and BoxLayout. BorderLayout arranges components in five regions (north, south, east, west, center) with one component per region. GridLayout arranges components in a rectangular grid with the same number of components per row. FlowLayout arranges components in a line, one after another. CardLayout displays one component at a time, treating each like a card. BoxLayout arranges components along an axis.
The document discusses XML namespaces and XML schemas. It provides examples of using namespaces to differentiate between similarly named elements, such as <highschool:subject> and <medicine:subject>. It also compares defining an XML document using a DTD versus using an XML schema, and provides a sample schema for defining book information. Key differences between "ref" and "type" attributes in schemas are explained using an employee example.
JDBC provides a standard interface for connecting to and working with databases in Java applications. There are four main types of JDBC drivers: Type 1 drivers use ODBC to connect to databases but are only compatible with Windows. Type 2 drivers use native database client libraries but require the libraries to be installed. Type 3 drivers use a middleware layer to support multiple database types without native libraries. Type 4 drivers connect directly to databases using a pure Java implementation, providing cross-platform compatibility without additional layers.
ActiveX is a framework for reusable software components that can be composed to provide application functionality. It was introduced by Microsoft in 1996 and is commonly used in Windows applications and allows components to be embedded in web pages. ActiveX controls can create distributed applications over the internet. They can provide more functionality than Java applets but only run on Internet Explorer and Windows. Malware has been spread using ActiveX controls installed from malicious websites.
JSP stands for Java Server Pages and enables developers to embed Java code directly into HTML pages. JSP pages have a .jsp extension and allow for platform-independent development since Java code can run on any system. The JSP request is sent to the web server, which passes the .jsp file to the JSP servlet engine. If it is the first request, the JSP file is parsed into a servlet class file; otherwise, an instantiated servlet handles the request. The servlet output is then sent to the user's browser.
The document discusses how to create and run ActiveX controls in Visual Basic. It provides steps to create a simple calculator ActiveX control and system clock ActiveX control. The key steps include starting Visual Basic, clicking on the ActiveX control, giving the project a name, adding coding for functionality, adding the component to the toolbox, dragging it onto a form, setting the project properties, and executing the ActiveX control.
Active Server Pages (ASP) was introduced in 1996 and bundled with Internet Information Server 3.0. ASP allows developers to create dynamic web pages by mixing standard HTML tags with server-side scripting code. Some key capabilities of ASP include generating dynamic web pages, processing HTML forms, creating database-driven pages, and tracking user sessions. The core ASP components include the Request, Response, Session, Server, and Error objects which provide functionality for handling requests, sending responses, storing session data, accessing server properties, and displaying error information.
This is the most important concept in advance java. Why java is so much popular than other? answer is its implicit objects. It provides many implicit object in the library. So you don't need to declare object to use it. You just have to use whenever you need it.
This document provides an overview of Active Server Pages (ASP) programming. It discusses the differences between client-side and server-side script processing. Client-side processing occurs on the user's computer browser using JavaScript, while server-side processing occurs on the web server using ASP scripts like VBScript. Server-side processing allows data to be stored in databases and controls user access, while client-side processing is faster but cannot retain global data. The document also reviews ASP implementation using IIS servers, and the Request and Response objects used to access information passed between the client and server.
Active Server Pages (ASP) is a technology that allows web pages to contain server-side scripting. When a browser requests an ASP file, the ASP engine processes the file by executing any scripts and then returns HTML to the browser. ASP files can contain HTML tags, scripting languages like VBScript, and server-side objects. Scripts in ASP files run on the server and allow dynamic content generation. The Request object provides access to form data submitted by users, and the Session object stores information about users across multiple pages of a website. Cookies are also used to store user-specific data on the client side.
This document provides an overview of scripting languages. It defines a script as a program or sequence of instructions interpreted by another program rather than the processor. Scripting languages are programming languages that support scripts and can interpret and automate tasks. The document discusses server-side scripting, which connects to databases on the web server and can access the file system. It also covers client-side scripting, which executes in the browser, and compares the advantages of server-side and client-side scripting. Popular scripting languages for each are also listed.
JSP AND XML USING JAVA WITH GET AND POST METHODSbharathiv53
This ppt contains JSP life cycle, Tags, Tomcat, Request String,
User Sessions, Cookies, Session Objects; XML - Tags, Elements,
Attributes, XML with CSS, XML and DTD (Document Type Definition),
XML Schema.
JSP (Java Server Pages) is a technology that allows the creation of dynamic web pages by embedding Java code in HTML pages. This provides a simpler way to add dynamic content to web pages compared to servlets. Some key points:
- JSP pages allow embedding of Java code in HTML pages using scripting elements like <% %> tags. This separates dynamic content from static content.
- JSP pages are compiled to servlets, separating the work of Java programmers and page authors.
- Common JSP elements include scriptlets, expressions, declarations, and directives that control things like page attributes and included files.
- JSP provides built-in support for HTTP sessions and can integrate with Java
This document provides an introduction and overview of JSP (JavaServer Pages) technology. Key points include:
- JSP pages allow for mixing HTML and Java code to create dynamic web applications more easily than servlets alone.
- JSP pages are translated into servlets by the web container before execution.
- JSP offers implicit objects, standard actions, tags and directives to simplify coding dynamic content.
- Exception handling and lifecycle management are similar to servlets in JSP.
- Java beans can be used to encapsulate reusable data and logic in JSP applications.
This slide is about basics of java servlet and java server page.
A basic example of JSP using multiple directives.
Further information of setting up and using of Apache Tomcat server.
JavaServer Pages (JSP) is a technology that allows developers to embed Java code in HTML pages to create dynamic web content. JSP pages combine HTML code with JSP actions and commands. At runtime, JSP pages are translated into Java servlets that generate the web page content dynamically. This provides better performance than CGI and allows embedding of dynamic elements directly into HTML pages.
The document provides an overview of JavaServer Pages (JSP) technology. It discusses what JSP is, how JSP pages work, common JSP elements like declarations, expressions, scriptlets, implicit objects, directives, and tags. Key points covered include how JSP pages are compiled into Java servlets, the JSP lifecycle, and how to include files, redirect to other pages, and use beans in JSP.
This document provides an overview of JSP (JavaServer Pages) basics. It discusses what JSP is, its advantages, the elements that make up a JSP file including directives, scripting elements, actions, and implicit objects. It also covers the JSP lifecycle, how JSP pages work, common directives like page and include, scripting elements like declarations, scriptlets and expressions, and standard actions like include, forward, useBean and setProperty. The document is intended to teach the fundamentals of JSP through explanations and examples.
Java Server Pages (JSP) allow developers to create dynamic web content by mixing static HTML markup with Java code. JSP pages are translated into Java servlets, providing access to full Java functionality. Key elements of JSP include tags for scripting Java code directly in HTML pages, and directives that control page processing. JSP provides a standard way to create dynamic web applications and interfaces with databases using Java.
This document discusses Java Server Pages (JSP) and compares it to servlets. It outlines some drawbacks of servlets, including that web page designers need knowledge of servlets and servlets have to be recompiled for each presentation change. It then describes advantages of JSPs such as allowing dynamic web page creation through combining HTML and scripting tags. The document also covers JSP directives, implicit objects, Java beans, and standard action tags like <jsp:useBean> and <jsp:include>.
- JSP allows embedding Java code within HTML pages using special tags, providing an alternative to plain Java servlets for generating dynamic web pages. The HTML pages are known as JSP files.
- JSP files are translated into Java servlets behind the scenes, with the Java code enclosed in tags executed on the server and HTML returned to the client. This allows generating HTML dynamically based on Java logic and data.
- Common JSP tags include scriptlets for Java code, expressions for outputting values, declarations, includes, and actions to control page flows like includes and redirects. Directives like import affect the compiled servlet class.
In this Java JSP Training session, you will learn JSP. Topics covered in this session are:
• JSP (Java Server Pages Technology)
• JSP vs Servlet
• MVC Architecture
• Scriplet
For more information, visit this link:
https://www.mindsmapped.com/courses/software-development/jsp-and-servlets-designing-web-applications-with-java/
This document provides an overview of Java Server Pages (JSP) technology. Some key points:
- JSP allows separation of work between web designers and developers by allowing HTML/CSS design and Java code to be placed in the same file.
- A JSP page is compiled into a servlet, so it can take advantage of servlet features like platform independence and database-driven applications.
- JSP pages use tags like <jsp:include> and <jsp:useBean> to include content and access JavaBeans. Scriptlets, expressions, declarations, and directives are also used.
- Implicit objects like request, response, out, and session are automatically available in JSP pages
JSP technology facilitates separating the work of web designers and developers. Web designers can create HTML layouts while developers write Java code and JSP tags for business logic. A JSP page compiles to a servlet, allowing incorporation of servlet functionality. Servlets and JSPs share features like platform independence and database-driven applications. However, servlets tie static and dynamic content to separate files requiring recompilation on changes, while JSPs allow embedding Java directly in HTML pages. The JSP lifecycle involves translation to a servlet by the container and processing of requests and responses.
The document discusses Java Server Pages (JSP) technology. It explains that JSP allows separation of work between web designers and developers by allowing HTML design and Java coding. A JSP page compiles to a servlet, sharing features with servlets like platform independence and database-driven applications. However, servlets tie static and dynamic content across multiple files while JSP allows embedding Java code directly into HTML pages. The document also covers JSP tags, directives, the JSP life cycle, and core JSP classes.
This document provides an overview of Java Server Pages (JSP) technology. It discusses how JSP pages combine HTML/XML markup with Java code to create dynamic web content. Key points include:
- JSP pages are converted into Java servlets by the JSP container/engine to generate HTML responses. This allows accessing Java APIs and databases.
- Common JSP elements like scriptlets, expressions, declarations, comments, and directives allow embedding Java code in JSP pages.
- The JSP lifecycle mirrors the servlet lifecycle with phases like initialization, execution, and destruction.
- Standard Tag Libraries (JSTL) provide commonly used tags to simplify tasks like iteration, conditionals,
The document discusses JavaServer Pages (JSP) technology. It provides details about:
- JSP is a popular server-side scripting language that provides dynamic web content using scripting elements and XML tags.
- Key features of JSP include ease of deployment, support for multithreading, reusable components, and cross-platform support.
- JSP pages are preprocessed into Java servlet classes that can be compiled and executed by the web container.
- JSP supports scripting elements like Java code embedded directly in tags, directives to control page behavior, and actions to convert elements to servlet code.
The document discusses Java Server Pages (JSP) technology which provides a simplified way to create dynamic web content. JSP pages are compiled into servlets, allowing developers to embed Java code directly into HTML pages to interact with databases and other applications. The document covers key aspects of JSP including its architecture, lifecycle, directives like include and taglib, and how it enables rapid development of web applications.
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
Java Hibernate Introduction, Architecture and Example with step by step guidance to run the program especially for students and teachers.
Learn More @ http://java2all.com/technology/hibernate
Network programming in java - PPT with Easy Programs and examples of Java InetAddress Class and java socket programming example.
Learn more @ http://java2all.com/technology/network-programming
This document provides an overview of web application development and servlet technology. It discusses the history and evolution of web pages to dynamic web applications. It then defines web applications and the request-response model. Common Gateway Interface (CGI) is introduced as the first technique for dynamic content, along with its limitations which led to the creation of servlets. Key servlet concepts like the servlet interface, generic servlet, HTTP servlet, and servlet lifecycle methods are covered. The document also examines the HttpServletRequest and HttpServletResponse interfaces and their various methods. Finally, it discusses session tracking approaches including cookies and the session API.
The document describes the steps to develop a simple remote method invocation (RMI) application in Java. It includes:
1. Defining a remote interface with methods like addition, subtraction etc.
2. Implementing the interface in a class that defines the method bodies.
3. Creating a server class that binds the remote object to the registry.
4. Making a client class that looks up the remote object and calls methods.
5. Compiling the classes, running the registry, then server and client separately to test the application.
The document discusses Remote Method Invocation (RMI) in Java. RMI allows objects running in one Java virtual machine to invoke methods on objects running in another Java VM. It has four layers: application layer, proxy layer, remote reference layer, and transport layer. The RMI architecture contains an RMI server, RMI client, and RMI registry. The server creates remote objects and registers them with the registry. The client looks up remote objects by name in the registry and invokes methods on them.
Jdbc example program with access and MySqlkamal kotecha
The document provides examples of using JDBC to connect to and interact with Microsoft Access and MySQL databases. It includes steps to create databases and tables in Access and MySQL, as well as code samples demonstrating how to connect to the databases using JDBC, execute queries using Statement and PreparedStatement, and retrieve and display result sets. Key aspects like loading the appropriate JDBC driver and connection strings for different databases are also explained.
The document discusses several JDBC APIs used for connecting Java applications to databases. The Connection interface is used to create a connection to a database and execute SQL statements. The Statement interface executes static SQL queries and retrieves results. The PreparedStatement interface executes dynamic queries with IN parameters by using placeholder values set using methods like setInt() and setString(). Examples of using these interfaces will be provided in subsequent chapters.
The document discusses three ways to handle errors in JSP:
1. Using Java exception handling mechanisms like try/catch blocks.
2. Specifying an error page using the errorPage attribute in the page directive.
3. Configuring error pages in the web deployment descriptor (web.xml) by mapping exceptions to error pages.
The document discusses String handling in Java. It describes how Strings are implemented as objects in Java rather than character arrays. It also summarizes various methods available in the String and StringBuffer classes for string concatenation, character extraction, comparison, modification, and value conversion. These methods allow extracting characters, comparing strings, modifying strings, and converting between string and other data types.
The document discusses Java wrapper classes. Wrapper classes wrap primitive data types like int, double, boolean in objects. This allows primitive types to be used like objects. The main wrapper classes are Byte, Short, Integer, Long, Character, Boolean, Double, Float. They provide methods to convert between primitive types and their wrapper objects. Constructors take primitive values or strings to create wrapper objects. Methods like parseInt() convert strings to primitive types.
The document discusses Java packages and classes. It describes common Java API packages like java.lang, java.util, java.io, java.awt, and java.net and what types of classes they contain. It also provides examples of using packages like Vector, Random, Date, and Calendar classes and their key methods. The Calendar class allows interpreting dates and times, defining constants used for components like MONTH, DATE, HOUR, etc.
Interfaces define methods that classes can implement. Classes implementing interfaces must define all interface methods. Interfaces can extend other interfaces, requiring implementing classes to define inherited methods as well. Interface variables are implicitly public, static, and final. A class can implement multiple interfaces and override methods with the same name across interfaces. Partial interface implementation requires the class to be abstract.
ppt of class and methods in java,recursion in java,nested class,java,command line argument,method overloading,call by value,call by reference,constructor overloading core java ppt
fundamental of class object and methods in core java, core java easy guide ppt of chapter 5 of http://www.java2all.com/
The document discusses control structures in Java, including selection (if/else statements), repetition (loops like while and for), and branching (break and continue). It provides examples of if/else, switch, while, do-while, for, and break/continue statements. The key structures allow sequencing, selecting between alternatives, and repeating actions in a program.
This document provides step-by-step instructions for creating a simple JavaServer Pages (JSP) web application using MyEclipse. It describes how to open MyEclipse, create a new web project, add JSP files to the project, deploy the project to a Tomcat server, and view the application in a web browser by entering the URL. The instructions include screenshots indicating where to click or enter information at each step.
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...parmarjuli1412
The document provides an overview of therapeutic communication, emphasizing its importance in nursing to address patient needs and establish effective relationships. THERAPEUTIC COMMUNICATION included some topics like introduction of COMMUNICATION, definition, types, process of communication, definition therapeutic communication, goal, techniques of therapeutic communication, non-therapeutic communication, few ways to improved therapeutic communication, characteristics of therapeutic communication, barrier of THERAPEUTIC RELATIONSHIP, introduction of interpersonal relationship, types of IPR, elements/ dynamics of IPR, introduction of therapeutic nurse patient relationship, definition, purpose, elements/characteristics , and phases of therapeutic communication, definition of Johari window, uses, what actually model represent and its areas, THERAPEUTIC IMPASSES and its management in 5th semester Bsc. nursing and 2nd GNM students
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxBelicia R.S
Role play : First Aid- CPR, Recovery position and Hand hygiene.
Scene 1: Three friends are shopping in a mall
Scene 2: One of the friend becomes victim to electric shock.
Scene 3: Arrival of a first aider
Steps:
Safety First
Evaluate the victim‘s condition
Call for help
Perform CPR- Secure an open airway, Chest compression, Recuse breaths.
Put the victim in Recovery position if unconscious and breathing normally.
Himachal Pradesh’s beautiful hills have long faced a challenge: limited access to quality education and career opportunities for students in remote towns and villages. Many young people had to leave their homes in search of better learning and growth, creating a gap between talent and opportunity.
Vikas Bansal, a visionary leader, decided to change this by bringing education directly to the heart of the Himalayas. He founded the Himalayan Group of Professional Institutions, offering courses in engineering, management, pharmacy, law, and more. These institutions are more than just schools—they are centers of hope and transformation.
By introducing digital classrooms, smart labs, and practical workshops, Vikas ensures that students receive modern, high-quality education without needing to leave their hometowns. His skill development programs prepare youth for real-world careers by teaching technical and leadership skills, with strong industry partnerships and hands-on training.
Vikas also focuses on inclusivity, providing scholarships, career counseling, and support to underprivileged and first-generation learners. His quiet but impactful leadership is turning Himachal Pradesh into a knowledge hub, empowering a new generation to build a brighter future right in their own hills.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. In this slide try to present the brief history of Chaulukyas of Gujrat up to Kumarpala To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
Chaulukya or Solanki was one of the Rajputs born from Agnikul. In the Vadnagar inscription, the origin of this dynasty is told from Brahma's Chauluk or Kamandalu. They ruled in Gujarat from the latter half of the tenth century to the beginning of the thirteenth century. Their capital was in Anahilwad. It is not certain whether it had any relation with the Chalukya dynasty of the south or not. It is worth mentioning that the name of the dynasty of the south was 'Chaluky' while the dynasty of Gujarat has been called 'Chaulukya'. The rulers of this dynasty were the supporters and patrons of Jainism.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
Ray Dalio How Countries go Broke the Big CycleDadang Solihin
A complete and practical understanding of the Big Debt Cycle. A much more practical understanding of how supply and demand really work compared to the conventional economic thinking. A complete and practical understanding of the Overall Big Cycle, which is driven by the Big Debt Cycle and the other major cycles, including the big political cycle within countries that changes political orders and the big geopolitical cycle that changes world orders.
Exploring Ocean Floor Features for Middle SchoolMarie
This 16 slide science reader is all about ocean floor features. It was made to use with middle school students.
You can download the PDF at thehomeschooldaily.com
Thanks! Marie
How to Manage Upselling of Subscriptions in Odoo 18Celine George
Subscriptions in Odoo 18 are designed to auto-renew indefinitely, ensuring continuous service for customers. However, businesses often need flexibility to adjust pricing or quantities based on evolving customer needs.
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobedienceRajdeep Bavaliya
Dive into the powerful journey from Thoreau’s 19th‑century essay to Gandhi’s mass movement, and discover how one man’s moral stand became the backbone of nonviolent resistance worldwide. Learn how conscience met strategy to spark revolutions, and why their legacy still inspires today’s social justice warriors. Uncover the evolution of civil disobedience. Don’t forget to like, share, and follow for more deep dives into the ideas that changed the world.
M.A. Sem - 2 | Presentation
Presentation Season - 2
Paper - 108: The American Literature
Submitted Date: April 2, 2025
Paper Name: The American Literature
Topic: Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
[Please copy the link and paste it into any web browser to access the content.]
Video Link: https://youtu.be/HXeq6utg7iQ
For a more in-depth discussion of this presentation, please visit the full blog post at the following link: https://rajdeepbavaliya2.blogspot.com/2025/04/thoreau-s-influence-on-gandhi-the-evolution-of-civil-disobedience.html
Please visit this blog to explore additional presentations from this season:
Hashtags:
#CivilDisobedience #ThoreauToGandhi #NonviolentResistance #Satyagraha #Transcendentalism #SocialJustice #HistoryUncovered #GandhiLegacy #ThoreauInfluence #PeacefulProtest
Keyword Tags:
civil disobedience, Thoreau, Gandhi, Satyagraha, nonviolent protest, transcendentalism, moral resistance, Gandhi Thoreau connection, social change, political philosophy
How to Create an Event in Odoo 18 - Odoo 18 SlidesCeline George
Creating an event in Odoo 18 is a straightforward process that allows you to manage various aspects of your event efficiently.
Odoo 18 Events Module is a powerful tool for organizing and managing events of all sizes, from conferences and workshops to webinars and meetups.
ABCs of Bookkeeping for Nonprofits TechSoup.pdfTechSoup
Accounting can be hard enough if you haven’t studied it in school. Nonprofit accounting is actually very different and more challenging still.
Need help? Join Nonprofit CPA and QuickBooks expert Gregg Bossen in this first-time webinar and learn the ABCs of keeping books for a nonprofit organization.
Key takeaways
* What accounting is and how it works
* How to read a financial statement
* What financial statements should be given to the board each month
* What three things nonprofits are required to track
What features to use in QuickBooks to track programs and grants
2. JSP Element
http://www.java2all.com
3. In previous example described in introduction
to JSP, We didn`t use any java statement or code in
the file. If the developer wants to put any java code
in that file then the developer can put it by the use
of jsp tags(elements).
There are mainly three group of jsp
tags(elements) available in java server page :
1 ) JSP Scripting elements
2 ) JSP Directive elements
3 ) JSP Standard Action elements
All three elements described in next three topic.
http://www.java2all.com
5. 1. JSP Scripting elements :
There are four types of tag in jsp scripting
elements.
a) JSP Declaration tag.
b) JSP scriptlet tag.
c) JSP Expression tag.
d) Comment tag.
Now we describe each tag in detail. http://www.java2all.com
6. a) JSP Declaration tag :
A JSP declaration lets you declare or define
variables and methods (fields) that use into the jsp
page.
Declaration tag Start with <%! And End with
%>
The Code placed inside this tag must end with a
semicolon (;).
Syntax: <%! Java Code; %>
http://www.java2all.com
7. <%! private int i = 10; %>
<%! private int squre(int i)
{
i=i*i;
return i;
}
%>
You can also put these codes in a single syntax
block of declaration like,
<%! private int i = 10;
private int squre(int i)
{
i=i*i;
return i;
}
%>
Note : The XML authors can use an alternative
syntax for JSP declaration tag:
http://www.java2all.com
8. <jsp:declaration>
Java code;
</jsp:declaration>
EX.
<jsp:declaration> private int i = 1; </jsp:declaration>
<jsp:declaration>
{
private int squre(int i)
i=i*i;
return i;
}
</jsp:declaration>
You can also put these codes in a single syntax block of
declaration like,
<jsp:declaration>
private int i = 1;
private int squre(int i)
{
i=i*i;
return i;
}
</jsp:declaration>
http://www.java2all.com
9. Remember that XML elements, unlike HTML
ones, are case sensitive. So be sure to use lowercase.
Declarations do not generate any output so the
developer uses declaration tag with JSP expression tag
or JSP scriptlet tag for generating an appropriate
output for display it in the appropriate browser.
http://www.java2all.com
10. b) JSP scriptlet tag :
A JSP scriptlet lets you declare or define any
java code that use into the jsp page.
scriptlet tag Start with <% and End with
%>
The Code placed inside this tag must end
with a semicolon (;).
Syntax: <% Java Code; %>
http://www.java2all.com
11. EX.
<%
int a = 10;
out.print("a ="+a);
%>
Note : The XML authors can use an alternative
syntax for JSP scriptlet tag.
<jsp:scriptlet>
Java code;
</jsp:scriptlet>
http://www.java2all.com
12. c) JSP Expression tag :
A JSP expression is used to insert Java values directly
into the output.
JSP Expression tag is use for evaluating any expression
and directly displays the output in appropriate web browser.
Expression tag Start with <%= and End with %>
The Code placed inside this tag not end with a
semicolon (;).
Syntax: <%= Java Code %>
http://www.java2all.com
13. For example. the following shows the date/time
that the page was requested:
Current time: <%= new java.util.Date() %>
Note : The XML authors can use an alternative
syntax for JSP expressions:
<jsp:expression>
Java Expression
</jsp:expression>
http://www.java2all.com
14. d) Comment tag :
Although you can always include HTML
comments in JSP pages, users can view these if they
view the page's source. If you don't want users to be
able to see your comments, embed them within the <
%-- ... --%> tag.
<html>
<head>
<title>Comment demo</title>
</head>
<body>
<p>This is simple demo of test the comment </p>
<!-- This is a comment. Comments are not displayed in the browser but displayed in view source -->
<%-- This is a comment. Comments are not displayed in the browser as well as not displayed in view
source also --%>
</body>
</html>
http://www.java2all.com
15. Output :
This is simple demo of test the comment.
Now right click on the browser and select the
view source so we can get the code in Notepad like,
<html>
<head>
<title>Comment demo page</title>
</head>
<body>
<p>This is simple demo of test the comment. </p>
<!-- This is a comment. Comments are not displayed in the browser but displayed in view source -->
</body>
</html>
In the view sorce code, the comment put in <%--
comment --%> will not display but the comment put
in <!—comment will display.
http://www.java2all.com
16. Now using these JSP Scripting elements, we are developing some
simple examples so the use of these tags can easily understood.
<html>
<head>
<title>Scripting Demo page</title>
</head>
<body>
<%-- declaration tag --%>
<%! int i = 10; %>
<%-- scriptlet tag --%>
<% out.print("i = "+i); %>
<br>
<br>
<% out.print("for loop execution start..........."); %>
<br>
<%
for(int j=1;j<=10;j++)
{
out.print("j = "+j);
%>
<br>
<%
}
http://www.java2all.com
17. out.print("for loop execution complete...........");
%>
<br>
<br>
<%-- expression tag --%>
<%! int a = 10;
int b = 20;
%>
The addition of two variable : a + b = 10 + 20 = <%= a+b %>
<br>
<br>
Current time : <%= new java.util.Date() %>
</body>
</html
http://www.java2all.com
18. Output :
i = 10
for loop execution start...........
j=1
j=2
j=3
j=4
j=5
j=6
j=7
j=8
j=9
j = 10
for loop execution complete...........
The addition of two variable : a + b = 10 + 20 = 30
Current time : Sun Feb 12 14:00:35 IST 2012
http://www.java2all.com
20. 2. JSP Directive elements :
A JSP directive gives special information about
the page to JSP Engine.
Each JSP goes through two phases:
(1) The first phase is known as translation time,
during which the JSP engine turns the file into
a servlet. (The step following from 1 to 5 in JSP
Architecture)
http://www.java2all.com
21. • The second phase is known as request time,
during which the resulting servlet is run to
actually generate the page. (The step following
from 6 to 9 in JSP Architecture)
The JSP engine handles the directives at translation
time because the JSP engine will translate a
particular directive into a servlet only for the first
time so the developer can get more speed for the
process of loading a JSP file in a future.
Syntax:
<%@ directive-name [attribute=”value”
attribute=”value”………….] %> http://www.java2all.com
22. Note : The XML syntax for defining directives
is
<jsp:directive.directiveType [attribute=”value”
attribute=”value”………….] /> Three main types of
directives are:
a) page directive
b) include directive
c) taglib directive
http://www.java2all.com
23. a) page directive :
The page directive is used to specify attributes
for the JSP page as a whole.
The page directive does not produce any
visible output when the page is requested but
change the way the JSP Engine processes the
page.
e.g., you can make session data unavailable to
a page by setting a session to FALSE.
http://www.java2all.com
24. Syntax:
<@ page [attribute=”value”
attribute=”value”………….] %>
The table given below describes the possible
attributes for the page directive.
http://www.java2all.com
25. Syntax
Attribute Description (default value is Example
in bold)
This tells the server about
the language to be used <%@ page
language in the JSP file. Presently language="java" language="java"
the only valid value for %>
this attribute is java.
This attribute defines the import="packag <%@ page
Import list of packages, each e.class" import="java.util.
separated by comma . *, java.io.*"%>
Indicates the superclass <%@ page
extends="packa
Extends of servlet when jsp extends="com.Co
ge.class"
translated in servlet. nnect"%>
http://www.java2all.com
26. true indicates session
should be bound to the
existing session if one
exists, otherwise a new session="true| <%@ page
Session
session should be created false" session="true"%>
and bound to it and false
indicates that no sessions
will be used.
specifies the buffer size buffer="sizekb| <%@ page
Buffer
for out and default is 8kb. none" buffer="8kb"%>
True indicates
multithreading and false <%@ page
isThreadSafe="tr
isThreadSafe indicates that the servlet isThreadSafe="tr
ue|false"
should implement ue"%>
SingleThreadModel
http://www.java2all.com
27. true indicates that the
buffer should be flushed
when it is full and false
autoflush="tru <%@ page
autoFlush indicates indicates that
e|false" autoFlush="true"%>
an exception should be
thrown when the buffer
overflows.
<%@ page
This defines a string that info="This is a simple
info="message
Info can be retrieved via the jsp file created by
"
getServletInfo method. Java2all team on 22
Feb 2011"%>
<%@ page
pageEncodin This defines data type of pageEncoding=
pageEncoding="ISO-
g page encoding. "ISO-8859-1"
8859-1"%>
contentType This specifies the MIME contentType=" <%@ page
type of the output. MIME-Type" contentType="text/h
tml;
charset=ISO-8859-1"
http://www.java2all.com
28. <%@ page
This defines isELIgnored="
isELIgnored isELIgnored="false
ENUM data type. true|false "
"%>
This indicates
whether or not <%@ page
isErrorPage="true
isErrorPage the current page isErrorPage="false
|false"
can act as the "%>
error page.
Define a URL to
another JSP that
is invoked if an <%@ page
errorPage unchecked errorPage="url" errorPage="error.j
runtime sp"%>
exception is
thrown.
http://www.java2all.com
29. <%@ page language="java"
import="java.util.*,java.io.*"
extends="com.Connect"
autoFlush="true"
errorPage="error.jsp"
info="This is a simple jsp file created by Java2all team on 22 Feb 2011"
isELIgnored="false"
isErrorPage="false"
session="true"
buffer="8kb"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
isThreadSafe="true"
%>
NOTE :
The XML equivalent of
<%@ page import="java.util.*" %> is
<jsp:directive.page import="java.util.*" />
http://www.java2all.com
30. b) include directive :
It allows a JSP developer to include source code
(static resource) of a file inside jsp file at the
specified place at a translation time.
Typically include files are used for headers,
footers, tables and navigation that are common to
multiple pages.
The included page should not be another
dynamic page so the included file does not need to be
a complete and valid JSP or servlet.
http://www.java2all.com
31. Syntax:
<%@ include file="/folder_name/file_name"%>
If the included file and JSP file are available in
the same folder then the folder name is not required in
syntax.
<%@ include file="file_name"%>
Now we are describe the include directive by
one simple example so the use of include directive in
JSP file is easily understand.
http://www.java2all.com
32. Step-1 : Create two folder in webRoot
(i) HTMLFILE and (ii) JSPFILE.
Step-2 : Create a new HTML file(Included.html) in
HTMLFILE folder.
Step-3 : Replace the source code of a
file(Included.html) by the below code.
<html>
<head>
<title> Included.html </title>
</head>
<body>
<b>This is HTML page which is include in JSP file by using directive include tag in JSP file.</b> <br>
</body>
</html>
http://www.java2all.com
33. Step-4 : Create a jsp file(IncludeDemo.jsp) in
JSPFILE folder.
Step-5 : Now replace the source code of a
file(IncludeDemo.jsp) by the below code.
<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title> IncludeDemo.jsp </title>
</head>
<body>
This is a JSP page. <br>
<%@ include file="/HTMLFILE/“Included.html"%>
</body>
</html>
http://www.java2all.com
34. Step-6 : Now Redeploy the Project and start the
Server.
Step-7 : Enter the appropriate URL in web-
browser.
http://www.java2all.com
35. Output :
This is a JSP page.
This is HTML page which is include in jsp file
by using directive include tag in jsp file.
http://www.java2all.com
36. c) taglib directive :
The taglib directive makes custom actions
available in current page through the use of tag
library.
Syntax:
<%@ taglib uri="tag Library_path"
prefix="tag_prefix"%>
uri ====> The absolute path (URL) of a Tag Library
Descriptor.
prefix ====> A unique prefix used to identify custom
tags from library used later in the JSP page. http://www.java2all.com
37. EX.
<%@ taglib uri="/tlds/TableGenerator.tld"
prefix="tg"%>
And if TableGenerator.tld defines a tag named
table, then the JSP file can contain tag of following
type:
<tg:table>
……….
……….
</tg:table>
NOTE : We discuss taglib directory in detail in
further chapter. http://www.java2all.com
38. JSP Standard Action elements
http://www.java2all.com
39. JSP Standard Action elements:
Actions are high-level JSP elements that create,
modify or use other objects.
Unlike directives and scripting elements, JSP are
coded using strict XML syntax form.
By the use of JSP actions elements you can
dynamically insert a file, reuse JavaBeans
components, forward the user to another page, or
generate HTML for the Java plugin etc.
http://www.java2all.com
41. (1) <jsp:param>
The <jsp:param> action is used to provide other
tags with additional information in the form of name
value pairs.
This action is used in conjunction with
jsp:include, jsp:forward and jsp:plugin actions.
Syntax :
<jsp:param name=”parameter_name”
value=”parameter_value” />
http://www.java2all.com
42. OR
<jsp:param name=”parameter_name”
value=”parameter_value”>
</ jsp:param>
For Example,
<jsp:param name=”font_size” value=”20” />
OR
<jsp:param name=”font_size” value=”20”>
</jsp:param >
http://www.java2all.com
43. (2) <jsp:include>
This action allows a static or dynamic resource
to be including in the JSP at request time.
If page is buffered then the buffer is flushed
prior to the inclusion.
Syntax :
<jsp:include page= “file_name” flush = “true|false”
/>
http://www.java2all.com
44. OR
<jsp:include page= “file_name” flush = “true|false” >
<jsp:param name=”parameter_name”
value=”parameter_value” />
</jsp:include >
NOTE :
A <jsp:include> action may have one or more
<jsp:param> tags in its body, to provide additional
name-value pairs.
http://www.java2all.com
45. Included.jsp :-
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Included.jsp</title>
</head>
<body>
This is the message of Included.jsp file..............<br>
</body>
</html>
Include.jsp :-
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Include.jsp</title>
</head>
<body>
This is the message of Include.jsp file..............<br>
<jsp:include page="Included.jsp" />
</body>
</html>
http://www.java2all.com
46. Now run the Included.jsp in the appropriate
browser so you can get the below output in the
browser,
Output:
This is the message of Include.jsp file..............
This is the message of Included.jsp file..............
Example-2 :
Write a simple program which demonstrate the
use of <jsp:param> in <jsp:include> action element.
http://www.java2all.com
47. Employee.jsp :-
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Employee.jsp</title>
</head>
<body>
<b><i><% out.print("Name : "+request.getParameter("name1")); %></i></b> <br>
<% out.print("He is a "+request.getParameter("profile1")+" dept. in Noble Engineering College -
Junagadh."); %> <br>
<b><i><% out.print("Name : "+request.getParameter("name2"));%></i></b><br>
<% out.print("He is a "+request.getParameter("profile2")+" dept. in Noble Engineering College -
Junagadh."); %>
</body>
</html>
http://www.java2all.com
48. Information.jsp :-
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Information.jsp</title>
</head>
<body>
<jsp:include page="Employee.jsp">
<jsp:param value="Prof. Ashutosh A. Abhangi" name="name1"/>
<jsp:param value="H.O.D. of Info. Tech. " name="profile1"/>
<jsp:param value="Prof. Kamal N. Kotecha" name="name2"/>
<jsp:param value="H.O.D. of C.S.E. " name="profile2"/>
</jsp:include>
</body>
</html>
http://www.java2all.com
49. Now run the Information.jsp in the appropriate
browser so you can get the below output in the
browser,
Output:
Name : Prof. Ashutosh A. Abhangi
He is a H.O.D. of Info. Tech. dept. in Noble
Engineering College - Junagadh.
Name : Prof. Kamal N. Kotecha
He is a H.O.D. of C.S.E. dept. in Noble Engineering
College - Junagadh.
http://www.java2all.com
50. NOTE : Difference between Directive include
and Action include element.
Included
Include Syntax Done when Parsing
Content
<%@include
file=”file_na Compilation
Directive Static Container
me”%> time
<jsp:include Request Not parsed
Static or
Action page=”file_n Processing but included
dynamic
ame”%> time in container
http://www.java2all.com
51. (3) <jsp:forward>
With the forward action, the current page stops
processing the request and forwards the request to
another page.
Execution never returns to the calling (current)
page.
Syntax :
<jsp:forward page= “file_name” />
OR
<jsp: forward page= “file_name”>
<jsp:param name=”parameter_name”
value=”parameter_value” />
</jsp: forward> http://www.java2all.com
52. The meaning as well as use of the attributes and
the <jsp:param> element are same as for
<jsp:Include> action element.
Example-1 :
Write a simple program which demonstrate the
<jsp:forward> action element.
Current.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Current.jsp</title>
</head>
<body>
This is a Current page
<jsp:forward page="Forward.jsp" />
</body>
</html>
http://www.java2all.com
53. Forward.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Forward.jsp</title>
</head>
<body>
Welcome, Forward is working now and this is a Forwarded page...............<br/>
</body>
</html>
Now run the Current.jsp in the appropriate
browser so you can get the below output in the
browser,
Output:
Welcome, Forward is working now and this is a
Forwarded page...............
http://www.java2all.com
56. Retry.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Retry.jsp</title>
</head>
<body>
Wrong User ID and Password, Please try again by click below link…………<br>
<b><i><a href="Login.jsp"> Login page </a></i></b>
</body>
</html>
Success.jsp :
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Success.jsp</title>
</head>
<body>
<h1>You are successfully login................. </h1>
</body>
</html>
http://www.java2all.com
57. Now run the Login.jsp in the appropriate
browser so you can get the below output,
http://www.java2all.com
58. Now put the,
User Name : aaaaaa
Password : jjjjjj
And click on Sign in button so you can get the
below output in browser,
Output :
Wrong User ID and Password, Please try again
by click below link……………………..
Login page
By clicking the Login page link, the Login.jsp
page is call and you can put the
http://www.java2all.com
59. User Name : Ashutosh
Password : java
And click on Sign in button so you can get the
below output in browser,
Output :
You are successfully login.................
http://www.java2all.com
60. (4) <jsp:fallback>
Syntax :
<jsp:fallback> text message for user </jsp:fallback>
A text message to display for the user if the
plug-in cannot be started.
If the plug-in starts but the applet or Bean does
not, the plug-in usually displays a popup window
explaining the error to the user.
Its use with <jsp:plugin> element. http://www.java2all.com
61. (5) <jsp:plugin>
By the use of <jsp:plugin> you can include an
applet and JavaBean in your JSP page. Syntax of
<jsp:plugin> is :
http://www.java2all.com
62. Syntax :
<jsp:plugin type="bean|applet“
code="className.class“
codebase="Path of className.class
after moving it in WebRoot“
[ name="name of bean or applet instance" ]
[ align="bottom|top|middle|left|right" ]
[ height="displayPixels" ]
[ width="displayPixels" ]
[ jreversion=" version of Java Runtime
environment " ]
................. >
http://www.java2all.com
64. Example-1 :
Write a simple application in which the applet is
used in JSP file by <jsp:plugin> action element.
• Create a Applet_Jsp.java file(applet) in default
package at src in your Web Project(JSP_EXAMPLE).
The source code of this java file(applet) are as
under,
http://www.java2all.com
65. Applet_Jsp.java :
import java.applet.Applet;
import java.awt.Button;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Applet_Jsp extends Applet implements ActionListener
{
public void init()
{
setBackground(Color.black);
Button r = new Button("RED");
add(r);
r.addActionListener(this);
Button g = new Button("GREEN");
add(g);
g.addActionListener(this);
Button b = new Button("BLUE");
add(b);
b.addActionListener(this);
}
http://www.java2all.com
66. public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("RED"))
setBackground(Color.red);
if(e.getActionCommand().equals("BLUE"))
setBackground(Color.blue);
if(e.getActionCommand().equals("GREEN"))
setBackground(Color.green);
}
}
(2) Now, Run this applet.
(3) Create one new folder, name is AppletClass in
WebRoot.
(3) Now,Copy the Applet_Jsp.class file(compile
file/Bytecode file) which is available at……………
workspace.metadata.me_tcatwebappsYour_Project_na
meWEB-INFclasses Applet_Jsp.class in AppletClass folder
in WebRoot. http://www.java2all.com
67. (4) Create a Applet_Use_In_Jsp.jsp file in JSPFILES
folder at your Web Project(JSP_EXAMPLE).
The source code of this jsp file are as under,
Applet_Use_In_Jsp.jsp :
<%@ page language="java" %>
<html>
<head>
<title>Applet_Use_In_Jsp.jsp</title>
</head>
<body>
<jsp:plugin type="applet" code="Applet_Jsp.class" codebase="
http://localhost:8080/JSP_EXAMPLE/AppletClass"
width="500" height="500">
<jsp:fallback>
<p>Unable to load Applet..............</p>
</jsp:fallback>
</jsp:plugin>
</body>
</html> http://www.java2all.com
68. • <jsp:useBean>
Forms are a very common method of
interactions in web sites.The standard way of
handling forms in JSP is to define a "bean".
For that you just need to define a class that has
a field corresponding to each field in the form.
The class contains the "setters" and “getter”
method of the form fields.
By this action element <jsp:useBean>, we use
java bean in a JSP page.
http://www.java2all.com
69. Syntax :
<jsp:useBean id="bean id" class="bean's class"
scope="page|request|session| application" />
Scope of <jsp:useBean> :
1. page: This is default value. It means that we can
use the Bean within the JSP page.
It indicates that the bean is only available on the
current page (stored in the PageContext of the
current page).
2. request: It means that we can use the Bean from
any JSP page processing the same request.
http://www.java2all.com
70. A value of request indicates that the bean is only
available for the current client request (stored in
the ServletRequest object).
3. session: It means that we use the Bean from
any Jsp page in the same session as the JSP page
that created the Bean.
A value of session indicates that the object is
available to all pages during the life of the current
HttpSession.
4. application: It means that we use the Bean from
any page in the same application as the Jsp page
that created the Bean. http://www.java2all.com
71. A value of application indicates that it is
available to all pages that share the same
ServletContext.
(7) <jsp:setProperty>
This action sets the value of a bean’s property.
Syntax :
<jsp:setProperty name="bean's id"
property="property Name”value="property value"/
>
http://www.java2all.com
72. (8) <jsp:getProperty>
This element retrieves the value of a bean
property, converts it to a string, and inserts it into the
output.
Syntax :
<jsp:getProperty name="bean's id"
property="property name"/>
Example : Write a simple program which
demonstrate the <jsp:useBean>,<jsp:getProperty>
and <jsp:setProperty> action elements.
http://www.java2all.com
73. Student_Data.java :
package bean;
public class Student_Data
{
private String name = null;
private String email = null;
private int age = 0;
public String getName()
{
return name;
}
public String getEmail()
{
return email;
}
public int getAge()
{
return age;
}
http://www.java2all.com
74. public void setName(String name)
{
this.name = name;
}
public void setEmail(String email)
{
this.email = email;
}
public void setAge(int age)
{
this.age = age;
}
}
http://www.java2all.com
76. Now run the BeanData.jsp in the appropriate
browser so you can get the below output in the
browser,
Output :
STUDENT DATA :
Name : Rahul
Email-ID : [email protected]
Age : 20
http://www.java2all.com