SlideShare a Scribd company logo
JSP and JSTL
Introduction to JSP
 It stands for Java Server Pages.
 It is a server side technology.
 It is used for creating web application.
 It is used to create dynamic web content.
 In this JSP tags are used to insert JAVA code into
HTML pages.
 It is an advanced version of Servlet Technology.
 It is a Web based technology helps us to create
dynamic and platform independent web pages.
 In this, Java code can be inserted in HTML/ XML
pages or both.
 JSP is first converted into servlet by JSP container
before processing the client’s request.
JSP pages are more advantageous
than Servlet:
 They are easy to maintain.
 No recompilation or redeployment is required.
 JSP has access to entire API of JAVA .
 JSP are extended version of Servlet
Features of JSP
 Coding in JSP is easy :- As it is just adding JAVA code to
HTML/XML.
 Reduction in the length of Code :- In JSP we use action
tags, custom tags etc.
 Connection to Database is easier :-It is easier to connect
website to database and allows to read or write data easily
to the database.
 Make Interactive websites :- In this we can create
dynamic web pages which helps user to interact in real
time environment.
 Portable, Powerful, flexible and easy to maintain :- as
these are browser and server independent.
 No Redeployment and No Re-Compilation :- It is
dynamic, secure and platform independent so no need to
re-compilation.
 Extension to Servlet :- as it has all features of servlets,
implicit objects and custom tags
syntax
 Declaration Tag :-It is used to declare variables.
Syntax:- <%! Dec var %>
Example:- <%! int var=10; %>
Syntax:- <%= expression %>
Example:- <% num1 = num1+num2 %>
Syntax:- <% -- JSP Comments %>
How to run JSP in Eclipse IDE
using Apache Tomcat Server
Step 1: In order to run JSP in Eclipse IDE, you need to
have Apache tomcat Server configured in Eclipse
IDE.
Create dynamic web project
Give a Project name and click Finish.
Create a JSP file. Right click on the
WebContent-> New -> Click on JSP File
Enter file name and click Finish.
Write some JSP codeRun the JSP project. Right
click on your JSP project -> Run as -> Click on
“Run on Server”.
Select the Server and click next.
Select the Server and click next.
Click on Add All -> Click Finish
JSP - Standard Tag Library
 The JavaServer Pages Standard Tag Library (JSTL) is a
collection of useful JSP tags which encapsulates the core
functionality common to many JSP applications.
 JSTL has support for common, structural tasks such as
iteration and conditionals, tags for manipulating XML
documents, internationalization tags, and SQL tags. It
also provides a framework for integrating the existing
custom tags with the JSTL tags.
Advantage of JSTL
 Fast Development JSTL provides many tags that
simplify the JSP.
 Code Reusability We can use the JSTL tags on
various pages.
 No need to use scriptlet tag It avoids the use of
scriptlet tag.
Install JSTL Library
To begin working with JSP tages you need to first install the JSTL
library. If you are using the Apache Tomcat container, then
follow these two steps −
Step 1 − Download the binary distribution from Apache Standard
Taglib and unpack the compressed file.
Step 2 − To use the Standard Taglib from its Jakarta Taglibs
distribution, simply copy the JAR files in the distribution's 'lib'
directory to your application's webappsROOTWEB-
INFlib directory.
To use any of the libraries, you must include a <taglib> directive
at the top of each JSP that uses the library.
Jsp and jstl
Classification of The JSTL
Tags
The JSTL tags can be classified, according to their
functions, into the following JSTL tag library groups that
can be used when creating a JSP page −
 Core Tags
 Formatting tags
 SQL tags
 XML tags
 JSTL Functions
Core Tags
S.No. Tag & Description
1 <c:out>Like <%= ... >, but for expressions.
2 <c:set >Sets the result of an expression evaluation in a 'scope'
3
<c:remove >Removes a scoped variable (from a particular scope, if specified).
4
<c:catch>Catches any Throwable that occurs in its body and optionally exposes it.
5
<c:if>Simple conditional tag which evalutes its body if the supplied condition is true.
6
<c:choose>Simple conditional tag that establishes a context for mutually exclusive conditional operations, marked
by <when> and <otherwise>.
7
<c:when>Subtag of <choose> that includes its body if its condition evalutes to 'true'.
8
<c:otherwise >Subtag of <choose> that follows the <when> tags and runs only if all of the prior conditions evaluated
to 'false'.
9
<c:import>Retrieves an absolute or relative URL and exposes its contents to either the page, a String in 'var', or a
Reader in 'varReader'.
10
<c:forEach >The basic iteration tag, accepting many different collection types and supporting subsetting and other
functionality .
11
<c:forTokens>Iterates over tokens, separated by the supplied delimeters.
12 <c:param>Adds a parameter to a containing 'import' tag's URL.
13 <c:redirect >Redirects to a new URL.
14 <c:url>Creates a URL with optional query parameters
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Tag Example</title>
</head>
<body>
<c:out value="${'Welcome to JSTL'}"/>
</body>
</html>
Java Servlet and JDBC Example | Insert data in
MySQL
to start with interfacing Java Servlet Program with
JDBC Connection:
 Proper JDBC Environment should set-up along with
database creation.
 To do so, download the mysql-connector.jar file from
the internet,
 As it is downloaded, move the jar file to the apache-
tomcat server folder,
 Place the file in lib folder present in the apache-
tomcat directory.
 To start with the basic concept of interfacing:
 Step 1: Creation of Database and Table in MySQL
Step 2: Implementation of required
Web-pages
<html>
<head>
<title>Insert Data</title>
</head>
<body>
<form action="./InsertData" method="post">
<p>ID:</p>
<input type="text" name="id"/>
<br/>
<p>String:</p>
<input type="text" name="string"/>
<br/><br/><br/>
<input type="submit"/>
</form>
</body>
</html>
Step 3: Creation of Java Servlet program with JDBC
Connection
to create a JDBC Connection steps are
1. Import all the packages
2. Register the JDBC Driver
3. Open a connection
4. Execute the query, and retrieve the result
5. Clean up the JDBC Environment
6. Create a separate class to create a connection of
database, as it is a lame process to writing the
same code snippet in all the program. Create a
.java file which returns a Connection object.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
// This class can be used to initialize the database connection
public class DatabaseConnection {
protected static Connection initializeDatabase()
throws SQLException, ClassNotFoundException
{
// Initialize all the information regarding
// Database Connection
String dbDriver = "com.mysql.jdbc.Driver";
String dbURL = "jdbc:mysql:// localhost:3306/";
// Database name to access
String dbName = "demoprj";
String dbUsername = "root";
String dbPassword = "root";
Class.forName(dbDriver);
Connection con = DriverManager.getConnection(dbURL + dbName,
dbUsername,
dbPassword);
return con;
}
}
To use this class method, create an object in Java Servlet programBelow
program shows Servlet Class which create a connection and insert the data in
the demo table,
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import
javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
// Import Database Connection Class
file
import code.DatabaseConnection;
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
try {
// Initialize the database
Connection con = DatabaseConnection.initializeDatabase();
// Create a SQL query to insert data into demo table
// demo table consists of two columns, so two '?' is used
PreparedStatement st = con
.prepareStatement("insert into demo values(?, ?)");
// For the first parameter,
// get the data using request object
// sets the data to st pointer
st.setInt(1, Integer.valueOf(request.getParameter("id")));
// Same for second parameter
st.setString(2, request.getParameter("string"));
// Execute the insert command using executeUpdate()
// to make changes in database
st.executeUpdate();
// Close all the connections
st.close();
con.close();
// Get a writer pointer
// to display the successful result
PrintWriter out = response.getWriter();
out.println("<html><body><b>Successfully Inserted"
+ "</b></body></html>");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
step 5: Get the data from the HTML fileTo get the
data from the HTML file, the request object is used
which calls getParameter() Method to fetch the data
from the channel. After successful insertion, the
writer object is created to display a success
message.
 After insertion operation from Servlet, data will be
reflected in MySQL Database
Ad

More Related Content

What's hot (20)

Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
Mehul Jariwala
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
TESTLINK INTEGRATOR
TESTLINK INTEGRATORTESTLINK INTEGRATOR
TESTLINK INTEGRATOR
Hirosh Tharaka
 
Playwright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern WebPlaywright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern Web
Applitools
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
Sara Torkey
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
Derek Willian Stavis
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
Bojan Golubović
 
Jsp tag library
Jsp tag libraryJsp tag library
Jsp tag library
sandeep54552
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
Renato Primavera
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Spring Security
Spring SecuritySpring Security
Spring Security
Knoldus Inc.
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
Tomáš Drenčák
 
software-architecture-patterns
software-architecture-patternssoftware-architecture-patterns
software-architecture-patterns
Pallav Kumar
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Arnold Asllani
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
Yao Nien Chung
 
MVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineMVVM with SwiftUI and Combine
MVVM with SwiftUI and Combine
Tai Lun Tseng
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
Playwright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern WebPlaywright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern Web
Applitools
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
Sara Torkey
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
Bojan Golubović
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
Renato Primavera
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
Tomáš Drenčák
 
software-architecture-patterns
software-architecture-patternssoftware-architecture-patterns
software-architecture-patterns
Pallav Kumar
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Arnold Asllani
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
Yao Nien Chung
 
MVVM with SwiftUI and Combine
MVVM with SwiftUI and CombineMVVM with SwiftUI and Combine
MVVM with SwiftUI and Combine
Tai Lun Tseng
 

Similar to Jsp and jstl (20)

DataBase Connectivity
DataBase ConnectivityDataBase Connectivity
DataBase Connectivity
Akankshaji
 
JSP APP DEVLOPMENT.pptx Related to Android App Development
JSP  APP DEVLOPMENT.pptx Related to Android App DevelopmentJSP  APP DEVLOPMENT.pptx Related to Android App Development
JSP APP DEVLOPMENT.pptx Related to Android App Development
BhawnaSaini45
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
siddhesh2466
 
Jdbc
JdbcJdbc
Jdbc
BindhuBhargaviTalasi
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
Kalpana T
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
Raghu nath
 
Unit 4 1 web technology uptu
Unit 4 1 web technology uptuUnit 4 1 web technology uptu
Unit 4 1 web technology uptu
Abhishek Kesharwani
 
Unit 4 web technology uptu
Unit 4 web technology uptuUnit 4 web technology uptu
Unit 4 web technology uptu
Abhishek Kesharwani
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
Manjunatha RK
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
Kaml Sah
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
Aren Zomorodian
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Jsp element
Jsp elementJsp element
Jsp element
kamal kotecha
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
Aravindharamanan S
 
Java server pages
Java server pagesJava server pages
Java server pages
Tanmoy Barman
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
NishaRohit6
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
Auwal Amshi
 
Bt0083 server side programing 2
Bt0083 server side programing  2Bt0083 server side programing  2
Bt0083 server side programing 2
Techglyphs
 
Ad

More from vishal choudhary (20)

function in php using like three type of function
function in php using  like three type of functionfunction in php using  like three type of function
function in php using like three type of function
vishal choudhary
 
data base connectivity in php using msql database
data base connectivity in php using msql databasedata base connectivity in php using msql database
data base connectivity in php using msql database
vishal choudhary
 
software evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall modelsoftware evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall model
vishal choudhary
 
software Engineering lecture on development life cycle
software Engineering lecture on development life cyclesoftware Engineering lecture on development life cycle
software Engineering lecture on development life cycle
vishal choudhary
 
strings in php how to use different data types in string
strings in php how to use different data types in stringstrings in php how to use different data types in string
strings in php how to use different data types in string
vishal choudhary
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT  questionOPEN SOURCE WEB APPLICATION DEVELOPMENT  question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
web performnace optimization using css minification
web performnace optimization using css minificationweb performnace optimization using css minification
web performnace optimization using css minification
vishal choudhary
 
web performance optimization using style
web performance optimization using styleweb performance optimization using style
web performance optimization using style
vishal choudhary
 
Data types and variables in php for writing and databse
Data types and variables in php for writing  and databseData types and variables in php for writing  and databse
Data types and variables in php for writing and databse
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
sofwtare standard for test plan it execution
sofwtare standard for test plan it executionsofwtare standard for test plan it execution
sofwtare standard for test plan it execution
vishal choudhary
 
Software test policy and test plan in development
Software test policy and test plan in developmentSoftware test policy and test plan in development
Software test policy and test plan in development
vishal choudhary
 
function in php like control loop and its uses
function in php like control loop and its usesfunction in php like control loop and its uses
function in php like control loop and its uses
vishal choudhary
 
introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
PHP introduction how to create and start php
PHP introduction how to create and start phpPHP introduction how to create and start php
PHP introduction how to create and start php
vishal choudhary
 
SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
vishal choudhary
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
vishal choudhary
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
vishal choudhary
 
function in php using like three type of function
function in php using  like three type of functionfunction in php using  like three type of function
function in php using like three type of function
vishal choudhary
 
data base connectivity in php using msql database
data base connectivity in php using msql databasedata base connectivity in php using msql database
data base connectivity in php using msql database
vishal choudhary
 
software evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall modelsoftware evelopment life cycle model and example of water fall model
software evelopment life cycle model and example of water fall model
vishal choudhary
 
software Engineering lecture on development life cycle
software Engineering lecture on development life cyclesoftware Engineering lecture on development life cycle
software Engineering lecture on development life cycle
vishal choudhary
 
strings in php how to use different data types in string
strings in php how to use different data types in stringstrings in php how to use different data types in string
strings in php how to use different data types in string
vishal choudhary
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT  questionOPEN SOURCE WEB APPLICATION DEVELOPMENT  question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
web performnace optimization using css minification
web performnace optimization using css minificationweb performnace optimization using css minification
web performnace optimization using css minification
vishal choudhary
 
web performance optimization using style
web performance optimization using styleweb performance optimization using style
web performance optimization using style
vishal choudhary
 
Data types and variables in php for writing and databse
Data types and variables in php for writing  and databseData types and variables in php for writing  and databse
Data types and variables in php for writing and databse
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
Data types and variables in php for writing
Data types and variables in php for writingData types and variables in php for writing
Data types and variables in php for writing
vishal choudhary
 
sofwtare standard for test plan it execution
sofwtare standard for test plan it executionsofwtare standard for test plan it execution
sofwtare standard for test plan it execution
vishal choudhary
 
Software test policy and test plan in development
Software test policy and test plan in developmentSoftware test policy and test plan in development
Software test policy and test plan in development
vishal choudhary
 
function in php like control loop and its uses
function in php like control loop and its usesfunction in php like control loop and its uses
function in php like control loop and its uses
vishal choudhary
 
introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
data type in php and its introduction to use
data type in php and its introduction to usedata type in php and its introduction to use
data type in php and its introduction to use
vishal choudhary
 
PHP introduction how to create and start php
PHP introduction how to create and start phpPHP introduction how to create and start php
PHP introduction how to create and start php
vishal choudhary
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
vishal choudhary
 
Ad

Recently uploaded (20)

Unit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theoriesUnit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theories
bharath321164
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Fundamentals of PR: Wk 4 - Strategic Communications
Fundamentals of PR: Wk 4 - Strategic CommunicationsFundamentals of PR: Wk 4 - Strategic Communications
Fundamentals of PR: Wk 4 - Strategic Communications
Jordan Williams
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
High Performance Liquid Chromatography .pptx
High Performance Liquid Chromatography .pptxHigh Performance Liquid Chromatography .pptx
High Performance Liquid Chromatography .pptx
Ayush Srivastava
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Open Access: Revamping Library Learning Resources.
Open Access: Revamping Library Learning Resources.Open Access: Revamping Library Learning Resources.
Open Access: Revamping Library Learning Resources.
Rishi Bankim Chandra Evening College, Naihati, North 24 Parganas, West Bengal, India
 
Unit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theoriesUnit 5: Dividend Decisions and its theories
Unit 5: Dividend Decisions and its theories
bharath321164
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Fundamentals of PR: Wk 4 - Strategic Communications
Fundamentals of PR: Wk 4 - Strategic CommunicationsFundamentals of PR: Wk 4 - Strategic Communications
Fundamentals of PR: Wk 4 - Strategic Communications
Jordan Williams
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
High Performance Liquid Chromatography .pptx
High Performance Liquid Chromatography .pptxHigh Performance Liquid Chromatography .pptx
High Performance Liquid Chromatography .pptx
Ayush Srivastava
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 

Jsp and jstl

  • 2. Introduction to JSP  It stands for Java Server Pages.  It is a server side technology.  It is used for creating web application.  It is used to create dynamic web content.  In this JSP tags are used to insert JAVA code into HTML pages.  It is an advanced version of Servlet Technology.  It is a Web based technology helps us to create dynamic and platform independent web pages.  In this, Java code can be inserted in HTML/ XML pages or both.  JSP is first converted into servlet by JSP container before processing the client’s request.
  • 3. JSP pages are more advantageous than Servlet:  They are easy to maintain.  No recompilation or redeployment is required.  JSP has access to entire API of JAVA .  JSP are extended version of Servlet
  • 4. Features of JSP  Coding in JSP is easy :- As it is just adding JAVA code to HTML/XML.  Reduction in the length of Code :- In JSP we use action tags, custom tags etc.  Connection to Database is easier :-It is easier to connect website to database and allows to read or write data easily to the database.  Make Interactive websites :- In this we can create dynamic web pages which helps user to interact in real time environment.  Portable, Powerful, flexible and easy to maintain :- as these are browser and server independent.  No Redeployment and No Re-Compilation :- It is dynamic, secure and platform independent so no need to re-compilation.  Extension to Servlet :- as it has all features of servlets, implicit objects and custom tags
  • 5. syntax  Declaration Tag :-It is used to declare variables. Syntax:- <%! Dec var %> Example:- <%! int var=10; %> Syntax:- <%= expression %> Example:- <% num1 = num1+num2 %> Syntax:- <% -- JSP Comments %>
  • 6. How to run JSP in Eclipse IDE using Apache Tomcat Server Step 1: In order to run JSP in Eclipse IDE, you need to have Apache tomcat Server configured in Eclipse IDE.
  • 8. Give a Project name and click Finish.
  • 9. Create a JSP file. Right click on the WebContent-> New -> Click on JSP File
  • 10. Enter file name and click Finish.
  • 11. Write some JSP codeRun the JSP project. Right click on your JSP project -> Run as -> Click on “Run on Server”.
  • 12. Select the Server and click next.
  • 13. Select the Server and click next.
  • 14. Click on Add All -> Click Finish
  • 15. JSP - Standard Tag Library  The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates the core functionality common to many JSP applications.  JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags. It also provides a framework for integrating the existing custom tags with the JSTL tags.
  • 16. Advantage of JSTL  Fast Development JSTL provides many tags that simplify the JSP.  Code Reusability We can use the JSTL tags on various pages.  No need to use scriptlet tag It avoids the use of scriptlet tag.
  • 17. Install JSTL Library To begin working with JSP tages you need to first install the JSTL library. If you are using the Apache Tomcat container, then follow these two steps − Step 1 − Download the binary distribution from Apache Standard Taglib and unpack the compressed file. Step 2 − To use the Standard Taglib from its Jakarta Taglibs distribution, simply copy the JAR files in the distribution's 'lib' directory to your application's webappsROOTWEB- INFlib directory. To use any of the libraries, you must include a <taglib> directive at the top of each JSP that uses the library.
  • 19. Classification of The JSTL Tags The JSTL tags can be classified, according to their functions, into the following JSTL tag library groups that can be used when creating a JSP page −  Core Tags  Formatting tags  SQL tags  XML tags  JSTL Functions
  • 20. Core Tags S.No. Tag & Description 1 <c:out>Like <%= ... >, but for expressions. 2 <c:set >Sets the result of an expression evaluation in a 'scope' 3 <c:remove >Removes a scoped variable (from a particular scope, if specified). 4 <c:catch>Catches any Throwable that occurs in its body and optionally exposes it. 5 <c:if>Simple conditional tag which evalutes its body if the supplied condition is true. 6 <c:choose>Simple conditional tag that establishes a context for mutually exclusive conditional operations, marked by <when> and <otherwise>. 7 <c:when>Subtag of <choose> that includes its body if its condition evalutes to 'true'. 8 <c:otherwise >Subtag of <choose> that follows the <when> tags and runs only if all of the prior conditions evaluated to 'false'. 9 <c:import>Retrieves an absolute or relative URL and exposes its contents to either the page, a String in 'var', or a Reader in 'varReader'. 10 <c:forEach >The basic iteration tag, accepting many different collection types and supporting subsetting and other functionality . 11 <c:forTokens>Iterates over tokens, separated by the supplied delimeters. 12 <c:param>Adds a parameter to a containing 'import' tag's URL. 13 <c:redirect >Redirects to a new URL. 14 <c:url>Creates a URL with optional query parameters
  • 21. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>Tag Example</title> </head> <body> <c:out value="${'Welcome to JSTL'}"/> </body> </html>
  • 22. Java Servlet and JDBC Example | Insert data in MySQL to start with interfacing Java Servlet Program with JDBC Connection:  Proper JDBC Environment should set-up along with database creation.  To do so, download the mysql-connector.jar file from the internet,  As it is downloaded, move the jar file to the apache- tomcat server folder,  Place the file in lib folder present in the apache- tomcat directory.  To start with the basic concept of interfacing:  Step 1: Creation of Database and Table in MySQL
  • 23. Step 2: Implementation of required Web-pages <html> <head> <title>Insert Data</title> </head> <body> <form action="./InsertData" method="post"> <p>ID:</p> <input type="text" name="id"/> <br/> <p>String:</p> <input type="text" name="string"/> <br/><br/><br/> <input type="submit"/> </form> </body> </html>
  • 24. Step 3: Creation of Java Servlet program with JDBC Connection to create a JDBC Connection steps are 1. Import all the packages 2. Register the JDBC Driver 3. Open a connection 4. Execute the query, and retrieve the result 5. Clean up the JDBC Environment 6. Create a separate class to create a connection of database, as it is a lame process to writing the same code snippet in all the program. Create a .java file which returns a Connection object.
  • 25. import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; // This class can be used to initialize the database connection public class DatabaseConnection { protected static Connection initializeDatabase() throws SQLException, ClassNotFoundException { // Initialize all the information regarding // Database Connection String dbDriver = "com.mysql.jdbc.Driver"; String dbURL = "jdbc:mysql:// localhost:3306/"; // Database name to access String dbName = "demoprj"; String dbUsername = "root"; String dbPassword = "root"; Class.forName(dbDriver); Connection con = DriverManager.getConnection(dbURL + dbName, dbUsername, dbPassword); return con; } }
  • 26. To use this class method, create an object in Java Servlet programBelow program shows Servlet Class which create a connection and insert the data in the demo table, import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse ; // Import Database Connection Class file import code.DatabaseConnection; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { // Initialize the database Connection con = DatabaseConnection.initializeDatabase(); // Create a SQL query to insert data into demo table // demo table consists of two columns, so two '?' is used PreparedStatement st = con .prepareStatement("insert into demo values(?, ?)"); // For the first parameter, // get the data using request object // sets the data to st pointer st.setInt(1, Integer.valueOf(request.getParameter("id"))); // Same for second parameter st.setString(2, request.getParameter("string")); // Execute the insert command using executeUpdate() // to make changes in database st.executeUpdate(); // Close all the connections st.close(); con.close(); // Get a writer pointer // to display the successful result PrintWriter out = response.getWriter(); out.println("<html><body><b>Successfully Inserted" + "</b></body></html>"); } catch (Exception e) { e.printStackTrace(); } } }
  • 27. step 5: Get the data from the HTML fileTo get the data from the HTML file, the request object is used which calls getParameter() Method to fetch the data from the channel. After successful insertion, the writer object is created to display a success message.  After insertion operation from Servlet, data will be reflected in MySQL Database