3. Introduction
• JavaServer Pages (JSP) is
a Java technology that helps software
developers serve dynamically generated
web pages based on HTML,XML, or other
document types.
• Released in 1999 as Sun's answer
to ASP and PHP .
3
4. Comparison
Function/Feature JSP PHP
Programming Completely Object Scripting language
Approach Oriented but way too with Object Oriented
descriptive. Support.
String and data Rich library Rich Functionality .
manipulation Inbuilt support to
include third party
libraries from other
languages.
Learning curve It helps if you have an If you know C/C++,
decent understanding then you are halfway
of JAVA and its through to learn PHP.
architecture.
Web Oriented Inbuilt Functionality Inbuilt Functionality
Features but way too much of but less lines of code
code. and less time to build
an application. 4
5. Advantages of JSP
• Versus Active Server Pages (ASP)
JSP is portable to other operating systems
and Web servers; you aren’t locked into
Windows.
• Versus Servlets
It is more convenient to write (and to
modify!) regular HTML than to have a zillion
println statements that generate the HTML.
5
6. Let’s Dive into the World of JSP
• What are JAVA servlets ?
Servlets are java programs that run on a web
server and are user to make webpages on a
fly (dynamic).
• Advantages of Servlets :
Powerful ,portable and Cheaper than many
other alternatives .
6
8. The Difference
• Servlets, make you generate the entire
page via your program, even though most
of it is always the same. JSP lets you
create the two parts separately.
• So everything a servlet can do JSP can
and further it is more easier to write .
• Developers & Designers at there best .
8
9. Let’s a build a basic app
• Setup and Installation
Step 1. Download and install a Java Developer
Kit.
Step 2. Download and install the Apache-
Tomcat web server.
Step 3. Open Your browser and type
http://localhost:8080 .
Step 4: Save your app inside the root folder in
apache .
Step 5: Type
http://localhost:8080/<appname.jsp> to run you 9
10. Time For Some Coding
<%@page contentType="text/html" import="java.util.*" %> 1st JSP tag
<html>
<body>
<p> </p>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="460"
bgcolor="#EEFFCA">
<tr>
<td width="100%"><font size="6" color="#008000"> Date
Example</font></td>
</tr>
<tr>
<td width="100%"><b> Current Date and time is: <font
color="#FF0000">
<%= new java.util.Date() %> 2nd JSP tag
</font></b></td>
</tr>
</table>
</center>
</div>
</body>
</html>
10
11. Another Example
Create a simple HTML page having the following
output :
Select Your Sport :
Cricket
Basketball
Soccer
Rugby
Hockey
11
12. JSP Coding Part
• <html>
<body>
<%! String[] sports; %>
<center>You have selected:
<%
sports = request.getParameterValues("sports");
if (sports != null)
{
for (int i = 0; i < sports.length; i++)
{
out.println ("<b>"+sports[i]+"<b>");
}
}
else out.println ("<b>none<b>");
%>
</center>
</body>
</html> 12
14. That Was Easy ..
• So with the help of some simple examples
we saw the Power of JSP.
One can make JSP work the way he/she
wants and develop a full fledged web app
with it ..
So , CODE & DESIGN ..
The world is all yours..
14