JSP FUNDAMENTALS
JSP FUNDAMENTALS
By: Hrishikesh Deshpande
Introduction :
JSP termed as Java Server Pages is a technology introduced by Sun Microsystems Inc. to develop the web application in more efficient way than Servlets. It has got many
Tutorial Details:
advanced features than servlets, one of them itself define the JSP i.e. JSP separates the presentation logic from the business logic and provide the designer and developer of the web application to work independently without any hassle.
Lets start with the basic of the JSPs, JSP is flavour of Cold fusion and ASP and hence provide the flexibility to embed the business logic efficiently within the HTML content (presentation logic).
JSP page is built using components such as :
Directives
Declarations
Scriplets
Expressions
Standard Actions
Custom Tags
Directives :
Listing some of them to start off :
1) Page
Syntax : < %@ page Language=?Java? extends=?? import=? or ? %>
Attributes:
a. Language = ?Java?
b. Import = ?Class?
c. Buffersize = ??
d. Scope = ?REQUEST/PAGE/SESSION/APPLICATION?
e. And etc?.
Page directive is aimed to define certain attribute of a JSP page for e.g. Language of the page in which the page content should be written , which class to be imported so that it can be used within the JSP page.
2) Include
Syntax: <%@ include file=?? %>
Attributes:
a. file = ??
This directive is to include the a HTML, JSP or Sevlet file into a JSP file. This is a static inclusion of file i.e. it will be included into the JSP file at the time of compilation and once the JSP file is compiled any changes in the included the file will not the reflected.
Declarations:
Syntax: <%! Declare all the variables here %>
Scriplets:
Syntax: <% All your scripts will come here %>
Expressions:
Syntax: <%= expression evaluation and display the variable %>
Standard Action:
Syntax:
Include ? />
This inclusion of file is dynamic and the specified file is included in the JSP file at run-time i.e. out put of the included file is inserted into the JSP file.
Forward ? />
This will redirect to the different page without notifying browser.
And many more.
Custom Tags:
taglib
Syntax: <%@ taglib uri=?? prefix=?? %>
Attributes:
a. uri = ??
b. prefix = ??
prefix is alias name for the tag library name.
JSP provides certain Implicit Objects listed below.
Object
Of Kind
Out
JSP writer
Request
HttpServletRequest
Response
HttpServletRespose
Session
HttpSession
Application
ServletContext
Config
Sevlet Config
Page
Object
PageContext
Page Context => is responsible for generating all other implicit objects.
Out:
This object is instantiated implicitly from JSP Writer class and can be used for displaying anything within delimiters.
For e.g. out.println(?Hi Buddy?);
Request:
It is also an implicit object of class HttpServletRequest class and using this object request parameters can be accessed.
For e.g. in case of retrieval of parameters from last form is as follows:
request.getParameters(?Name?);
Where ?Name? is the form element.
Response:
It is also an implicit object of class HttpServletResponse class and using this object response(sent back to browser) parameters can be modified or set.
For e.g. in case of modifying the HTTP headers you can use this object.
Response.setBufferSize(?50?);
Session:
Session object is of class HttpSession and used to maintain the session information. It stores the information in Name-Value pair.
For e.g.
session.setValue(?Name?,?Jakes?);
session.setValue(?Age?,?22?);
Application:
This object belongs to class SevletContext and used to maintain certain information throughout the scope of Application.
For e.g.
Application.setValue(?servername?,?www.myserver.com?);
PageContext:
This object is of class pageContext and is utilized to access the other implicit objects.
Connection Pooling
<%@ page language=" Java " import=" javax.naming.*,javax.sql.*,java.sql.*,java.util.* "%>
<%
try {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"t3://ramses:7001");
InitialContext ic = new InitialContext(p);
DataSource ds = (DataSource)ic.lookup("demoPool");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
int i = stmt.executeUpdate(
"insert into employee values('" + empEli.getFirstName() + "','" + empEli.getLastName() + "')" );
}
catch(Exception ex) {
ex.printStackTrace();
}
%>
Employee Firstname is :
Employee Lastname is :
Here we are using the property feature to store all the attributes required to use the connection pool like INITIAL_CONTEXT_FACTORY, PROVIDER_URL.
DataSource ds = (DataSource)ic.lookup("demoPool");
This statement looks up for the connection pool already configured in the particular Application Server. Here the name of the connection pool is named as demoPool .
Connection con = ds.getConnection();
This statement gets hold of an connection to the database from the pool of database connections already existing with the application server.
The rest of the statements are standard JDBC statements used in a normal connection to the database.
JSP FUNDAMENTALS JSPFUNDAMENTALSJSPFUNDAMENTALS...;
JSP termed as Java Server Pages... than servlets, one of
them itself define the JSP i.e. JSP separates
JSP Training
applications and all the fundamentals of JSP programming.
Prerequisites: Html...
JSP Training
JSP Training...;
Java Server Pages (JSP) is Sun's solution
JSP Tutorials
in
JSTL
JSPFundamentals... FundamentalsJSP termed as Java Server Pages is a technology
introduced...
JSP Tutorial - Java Server Pages Tutorials
JSP
Introduction to the JSP Java Server Pages
in
JSTL
JSPFundamentals... FundamentalsJSP termed as Java Server Pages is a technology
introduced...
JSP Tutorial - Java Server Pages Tutorials
JSP
JSP Programming Books
from JSPfundamentals to application design and deployment. The introductory...
JSP Programming Books
JSP Programming Books... applications and services.
Servlets and JSP technology is the foundation
Free JSP Books
technology, covering everything from JSPfundamentals to application design...
Free JSP Books
Free JSP Books
 ...;
Web Server Java: Servlets and JSP
This chapter covers Web Server Java
Java Server Faces (JSF)
To understand the fundamentals of the JSF framework and how it can be used... in configuring JSF.
To discover how JSF integrates with JSP... Server pages.
Java
JSP
Hibernate Training
Learning Fundamentals of
Hibernate by using the Hibernate...;
Updating Data
An Add/Edit JSP Page ...-to-One
JSP Pages 
JSP Include jsp JSP Include jspJSP Include jsp...;
This section illustrates you about the <jsp:include> directive
in jsp. With the <jsp:include> directive, you can include either
JSP CheckBox JSP CheckBox
JSP CheckBox...;
JSP CheckBox is used to create a CheckBox in JSP. The JSP Page... an elaborate example from 'JSP CheckBox'. To
understand and grasp the example we
JSP Interview : JSP Interview Questions -2 JSP Interview Questions
JSP Interview : JSP Interview...;
Page of the JSP Interview Questions.
Question: What is JSP Custom tags?
Answer: JSP Custom tags are user
Comments in Jsp
Comments in Jsp
Comments in Jsp...;
In a jsp we should always try to use jsp- style
comments unless you want the comments to appear in the HTML. Jsp comments are
converted
Introduction to JSP tags JSP Directives
Introduction to JSP tags JSP Directives
INTRODUCTION TO JSP TAGS
 ... the various tags available in JSP with
suitable examples. In JSP tags
Jsp redirect Jsp redirect
Jsp redirect...;
In this section, you will learn how to redirect a page in JSP. You... redirect the jsp
page in a jsp.
Here is the code of redirect.jsp
<html>
<
JSP Create Variable JSP Create Variable
JSP Create Variable...;
JSP Create Variable is used to create a variable in jsp. The scriptlets
include a java code to be written as <%! %> provided
INTRODUCTION TO JSP SCRIPTLETS
Introduction to JSP Scriptlets
INTRODUCTION TO JSP...;
Syntax of JSP Scriptles are:
<%
//java codes
%>
JSP
Introduction to JSP JSP Tutorials - Writing First JSP, Learn JSP, JSP Example
JSP Tutorials - Writing First JSP
 ... or JSP for short is Sun's solution for developing dynamic web sites. JSP provide
Introduction to JSP
Introduction to JSP
Introduction to JSP...;
Java Server Pages or JSP is Sun's solution used for developing dynamic web sites. JSP stands for Java Server Pages, a technology invented
INTRODUCTION TO JSP DECLARATIVES
Introduction to JSP Declaratives Declarations
INTRODUCTION TO JSP DECLARATIVES
 ...;
Syntax of JSP
Comments in Jsp
Comments in Jsp
Comments in Jsp...;
In a jsp we should always try to use jsp- style
comments unless you want the comments to appear in the HTML. Jsp comments are
converted
JSP Modulus JSP Modulus
JSP Modulus...;
JSP Modulus is used to determine the modulus of number in jsp...
In this section, you will learn how to determine the modulus of number
in jsp. As you already
JSP import
Java Certification
JSP
import
 ...;
An import is the attribute of the page
directive in JSP that imports the java packages
and it's classes whenever required for the JSP page.
More than
Introduction to JSP Scriptlets
Introduction to JSP Scriptlets
INTRODUCTION TO JSP...;
Syntax of JSP Scriptles are:
<%
//java codes
%>
JSP
JSP Actions JSP Actions
JSP Actions
 ...;
In this section we will explain you about JSP Action
tags and in the next section we will explain the uses of these tags with
examples. We will also show how to use JSP
JSP for Each JSP for Each
JSP for Each...;
The JSP for Each helps you to iterate over the data in JSP... illustrate an example from 'JSP for Each'. To understand the
example we make
JSP Architecture JSP Architecture
JSP ARCHITECTURE...;
JSP
pages are high level extension of servlet and it enable the developers
to embed java code in html pages. JSP
JSP Plugin JSP Plugin
JSP Plugin
 ...;
Syntax: <jsp: plugin type = "bean |applet" code = "ClassFileName" codeBase =
"ClassFileDirectoryName">
The <jsp:plugin> is used
JSP Tag Libraries JSP Tag Libraries
JSP Tag Libraries...;
JSP Tag Libraries
is the collection of standard tags. JSP tags are the Java components that can be
used in a JSP file. JSP tag libraries allow us to
make Java
JSP Current Path JSP Current Path
JSP Current Path...;
JSP Current Path is used to get the current path of the JSP page.
Understand with Example
The Tutorial illustrate an example from 'JSP
JSP Include File JSP Include File
JSP Include File...;
JSP Include File is used to insert a html file and the text file in the jsp
page when the JSP page is compiled. The insert file can
JSP Variable in Javascript JSP Variable in Javascript
JSP Variable...;
JSP Variable in Javascript helps you to pass jsp variable to javascript. The JavaScript
include a function that takes
JSP Error 500 JSP Error 500
JSP Error 500...;
JSP Error 500 is to generate error status 500 in jsp. ... will learn how to generate error status 500 in jsp. You
can see in the given example
JSP Include Param JSP Include Param
JSP Include Param...;
JSP Include Param is used to pass parameter in the include directive. The
example uses <jsp:param> clause to pass the parameter
JSP Window. Open JSP Window. Open
JSP Window. Open...;
JSP Window. Open is used to open a new window in JSP. The JavaScript
function window.open( ) open a new browser window
How JSP Forwards a request
How JSP Forwards a request
How JSP Forwards a request...;
In this section you will study how jsp forwards a request.
The <jsp:forward> forwards the request information from one
Implementing Bean with scriptlet in JSP
Implementing Bean with scriplet in JSP
Implementing Bean with scriptlet in JSP
 ...;
Example for implementing bean with scriptlet <% code %> in a JSP
The Include Directive in JSP Page
The Include Directive in JSP Page
The Include Directive in JSP Page
 ... the include
directive of the JSP. You will learn about what is include and how
Core Java Training Topics
To teach fundamentals of Java
programming language and how....
Core Java Training Course
Outline
1. Fundamentals
JSP Alert Jsp Alert
JSP Alert...;
JSP Alert is used to put the validation on login page for the users... form
using Javascript method in JSP page.
Understand with Example
JSP Hosting
JSP Hosting
JSP Directives and HTML tags JSP Directives and HTML tags
JSP Directives and HTML...;
JSP directives are as a message from a JSP page to the
JSP container that control the processing of the entire page. JSP directives
Multiple Methods in Jsp
Multiple Methods in Jsp
Multiple Methods in Jsp...;
Jsp is used mainly for presentation logic. In the jsp
we can declare methods just like as we declare methods in java classes
Passing Parameters in jsp
Passing Parameters in jsp
Passing Parameters in jsp...;
This section illustrates you how to pass parameters in jsp.
JSP can access the HTTP request object. It provides getParameter() method
Jsp Absolute Path Jsp Absolute Path
Jsp Absolute Path... in jsp. The absolute
path is the full path that contains the root directory... the absolute
path of jsp file, we have used the method getServletContext
JSP 2.0 - New Features
Free JSP download Books
Features of JSP 2.0...;
JSP 2.0 is released with new promises. JSP 2.0 is
an upgrade to JSP 1.2 with several new and interesting features
JSP Request URI JSP Request URI
JSP Request URI...;
JSP Request URI is used to return the URI of the current page in jsp. The
method request.getRequestURI( ) return you the request object
JSP Interview Questions JSP Interview Questions
JSP Interview Questions...;
Question: What do you understand by JSP
Actions?
Answer: JSP actions are XML tags that direct the server to use existing
JSP Value to JavaScript JSP Value to JavaScript
JSP Value to JavaScript...;
JSP Value to JavaScript tells you to pass the value from JSP to JavaScript.
The JavaScript create a function that accepts