JSP Ratan 9am
JSP Ratan 9am
JSP Ratan 9am
JSP Day-1
jsp we can write the programming at client side to render the proper response to browser.
2. Jsp is extension of servlets so we can use all features of servlets in addition we can use,
3. jsp tag based programming basics of java sufficient to understand the JSP
4. Servlets are best for more processing logics but jsp are best to develop dynamic web pages for more presentation logics
rather than processing logics.
5. Servlets are present in classes folder : private area : to Access the private area servlet use web.xml
jsp are present in webcontent folder along with html code : public area : to access the jsp web.xml is optional.
jsp are tag based : when we are doing modifications : just refresh will reflect the modifications.
every jsp internally converted servlet that converted servlet executed we will get the response.
11. The present version of servlets is 4.0 & present version of jsp is 2.3
12. MVC : In MVC jsp acts as a view part & servlets acts as a controller part.
javax.servlet
javax.servlet.http
javax.servlet.annotation
Javax.servlet.jsp
Javax.servlet.jsp.tagext
Login.html:
<html>
<body>
</form>
</body>
</html>
LoginServlet.java:-
package com.dss;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/LoginServlet")
public LoginServlet() { }
response.setContentType("text/html");
out.println("<html><body>");
out.println("</body></html>");
else{
out.println("<html><body>");
out.println("</body></html>");
}
response.setContentType("text/html");
RequestDispatcher rd = request.getRequestDispatcher("/Success.jsp");
rd.forward(request, response);
else
RequestDispatcher rd = request.getRequestDispatcher("/Failure.jsp");
rd.forward(request, response);
Success.jsp:
<html>
<body>
</body>
</html>
Failure.jsp:
<html>
<body>
<h1><font color="red"/>Invalid Username or Password</h1>
</body>
</html>
//first.jsp
pageEncoding="ISO-8859-1"%>
<html>
<body>
</body>
</html>
http://localhost:8888/JapApp1/first.jsp
HttpJspBase(c)
trans |
E:\advjava9amonline\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JapApp1\org\apache\j
sp
//first_jsp.java
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
javax.servlet.jsp.JspFactory.getDefaultFactory();
static {
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = null;
return _jspx_dependants;
return _jspx_imports_packages;
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory =
_jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
return _el_expressionfactory;
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager =
org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
return _jsp_instancemanager;
if ("OPTIONS".equals(_jspx_method)) {
return;
return;
try {
response.setContentType("text/html; charset=ISO-8859-1");
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
out = _jspx_out;
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
} catch (java.io.IOException e) {}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
Jsp Day-2
//Predefined support :
Servlet
JSPPage(i) GenericServlet
| |
HttpJspPage(i) HttpServlet
HttpJspBase(c)
trans |
Jsppage :
_jspInit()
_jspDestory()
HttpJspPage:
_jspService()
//Request process
Note: The jsp translation is done only once when send the first request.
from second request onwards directly converted servlet service() executed we will get the response.
In this model jsp alone responsible to write presentation logics & businness layer & model component.
//Jsp components :
Directives
page
include
taglib
Scritping elements
scriptlets
declarations
expression
comments
jsp action:
standred actions
custom actions
//Implicit objects :
<%!
String uname;
String pwd;
%>
Scriptlets: used to write the block of java code
<%
{ out.println("this is jsp");
%>
<%
uname = request.getParameter("uname");
pwd = request.getParameter("pwd");
%>
comments:
jsp comments
xml based
//login.html
<html>
<body>
</form>
</body>
</html>
//LoginAction.jsp
pageEncoding="ISO-8859-1"%>
<html>
<body>
<%!
String uname;
String upwd;
%>
<%
uname = request.getParameter("username");
upwd = request.getParameter("password");
{ out.println("login success");
else
{ out.println("login failure");
%>
<br/>
<br/>
</body>
</html>
<%
uname = request.getParameter("username");
upwd = request.getParameter("password");
{ response.sendRedirect("http://www.facebook.com");
else
%>
E:\advjava9amonline\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JspLoginPage\org\apa
che\jsp
jsp Day-3
Directives:
page
Page Directive can be used to define the present Jsp page characteristics like to define import statements,
specify particular super class to the translated servlet, to specify metadata about present Jsp pages and so on.
<%@page [attribute-list]%>
language:
<%@page language="java"%>
contentType:
This attribute will take a particular MIME type in order to give an intimation to the client about to specify the type
of response which Jsp page has generated.
<%@page contentType="text/html"%>
This attribute can be used to import a particular packages into the present Jsp pages.
<%@page import="java.io.*"%>
<%@page import="java.io.*",import="java.lang.*"%>
info :
ex:
<html>
<body>
<%!Date d=null;%>
<%
d = new Date();
%>
</body>
</html>
errorPage:
This attribute can be used to specify an error page to execute when we have an exception in the present Jsp page.
<%@page errorPage="error.jsp"%>
isErrorPage:
It is a boolean attribute, it can be used to give an intimation to the container about to allow or not to allow exception
implicit object into the present Jsp page.
If we provide value as true to this attribute then container will allow exception implicit object into the present Jsp page.
If we provide value as false to this attribute then container will not allow exception implicit object into the present Jsp
page.
<%@page isErrorPage=”true”%>
<html>
<body>
<%!Date d=null;%>
</body>
</html>
//myerror.jsp
<html>
<body>
</body>
</html>
buffer:
This attribute can be used to specify the particular size to the buffer available in JspWriter object.
Note: Jsp technology is having its own writer object to track the generated dynamic response, JspWriter will provide very
good performance when compared with PrintWriter in servlets.
<%@page buffer="52kb"%>
autoFlush:
It is a boolean attribute, it can be used to give an intimation to the container about to flush or not to flush dynamic
response to client automatically when JspWriter buffer filled with the response completely.
If autoFlush attribute value is true then container will flush the complete response to the client from the buffer
when it reaches its maximum capacity.
If autoFlush attribute value is false then container will raise an exception when the buffer is filled with the
response.
<html>
<body>
<%
for(int i=0;i<100000;i++)
%>
</body>
</html>
extends:
This attribute will take a particular class name, it will be available to the translated servlet as super class.
<%@page extends="com.dss.MyClass"%>
Where MyClass should be an implementation class to HttpJspPage interface and should be a subclass to
HttpServlet.
session:
It is a Boolean attribute, it is give intimation to the container about to allow or not to allow session implicit object into the
present Jsp page.The default value of this attribute is true.
isThreadSafe:
It is a boolean attribute, it can be used to give an intimation to the container about to allow or not to allow multiple
number of requests at a time into the present Jsp page.
If we provide true as value to this attribute then container will allow multiple number of requests at a time.
If we provide false as value to this attribute then automatically container will allow only one request at a time and it will
implement SingleThreadModel interface in the translated servlet.
The default value of this attribute is true.
<%@page isThreadSafe="false" %> : only one thred is allow to access this jsp
isELIgnored:
It is a boolean attribute, it can be used to give an intimation to the container about to allow or not to allow
Expression Language syntaxes in the present Jsp page.
Note: Expression Language is a Scripting language, it can be used to eliminate java code completely from the Jsp pages.
If isELIgnored attribute value is true then container will eliminate Expression Language syntaxes from the present Jsp page.
If we provide false as value to this attribute then container will allow Expression Language syntaxes into the present Jsp
pages.
<%@page isELIgnored="true"%>
9. <jsp:params---->
jsp Day-4
The common code across all JSP pages recommended to write once in a separate JSP page, and include this JSP across all
other JSPs using <%@ include %> directive.
The main advantage with this approach is to promote Reusability and Maintainability.
<%@include file=”--”%>
Where file attribute can be used to specify the name and location of the target resource.
logo.jsp:
<html>
<body><center>
</font></b></center></td></tr>
</table></center></body>
</html>
footer.jsp:
<html>
<body><center>
copyrights2010-2020@Ratansoftwaresolutions
</font></b></center></td></tr>
</table></center></body>
</html>
body.jsp:
<html>
<body bgcolor="lightyellow">
<center><b><font size="7">
<p><br>
<br><br></p>
</font></b></center></body>
</html>
mainpage1.jsp:
<%@include file="logo.jsp"%>
<%@include file="body.jsp"%>
<%@include file="footer.jsp"%>
mainpage2.jsp:
<%@include file="logo.jsp"%>
<%@include file="body.jsp"%>
<%@include file="footer.jsp"%>
Note : in including mechanism all the dependent file content Is included in main file during translation page hence it is
static inclusion.
<jsp:include page="logo.jsp"/>
<jsp:include page="body.jsp"/>
<jsp:include page="footer.jsp"/>
Note :
Page
Request
Session
Application
Page scope:
‘page’ scope means, the JSP object can be accessed only from within the same page where it was created.
The default scope for JSP objects created using <jsp:useBean> tag is page.
JSP implicit objects out, exception, response, pageContext, config and page have ‘page’ scope.
Request scope:
A JSP object created using the ‘request’ scope can be accessed from any pages that serves that request. More than one
page can serve a single request. The JSP object will be bound to the request object.
Session scope :
‘session’ scope means, the JSP object is accessible from pages that belong to the same session from where it was
created. The JSP object that is created using the session scope is bound to the session object.
Application scope:
A JSP object created using the ‘application’ scope can be accessed from any pages across the application. The JSP
object is bound to the application object.
PageContext:
pageContext Object used to store the data temprarly any of the the four scopes.
The PageContext object is used to set or get or remove the the attributes form fallowing scopes,
Page
Request
Session
Application
form.html:
<html>
<body>
</form>
</body>
</html>
Welcome.jsp:-
<html>
<body>
<%
pageContext.setAttribute("uname",uname, PageContext.SESSION_SCOPE);
%>
</body>
</html>
Second.jsp:-
<html>
<body>
out.println("Welcome="+uname);
%>
</body>
</html>
In Jsp technology, by using scripting elements we are able to provide java code inside the Jsp pages,
but the main theme of Jsp technology is not to allow java code inside Jsp pages.
write the java separate, we can configure the java code using standred actions.
1. <jsp:useBean---->
2. <jsp:setProperty---->
3. <jsp:getProperty---->
4. <jsp:include---->
5. <jsp:forward---->
6. <jsp:param---->
7. <jsp:params---->
7. <jsp:plugin---->
8. <jsp:fallback---->
JSTL: giving some more tags to configure the java code. Just like standred actions.
Jsp Day-5
To give init-param & context param we have to configure the jsp in web.xml
<web-app>
<servlet>
<servlet-name>FirstJsp</servlet-name>
<jsp-file>/first.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>FirstJsp</servlet-name>
<url-pattern>/first</url-pattern>
</servlet-mapping>
</web-app>
//form.html
<html><body>
//web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>CCJSP</display-name>
<welcome-file-list>
<welcome-file>form.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>username</param-name>
<param-value>system</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>manager</param-value>
</context-param>
<servlet>
<servlet-name>FirstJsp</servlet-name>
<jsp-file>/first.jsp</jsp-file>
<init-param>
<param-name>animal1</param-name>
<param-value>Tiger</param-value>
</init-param>
<init-param>
<param-name>animal2</param-name>
<param-value>Lion</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>FirstJsp</servlet-name>
<url-pattern>/first</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>aaa</servlet-name>
<jsp-file>/second.jsp</jsp-file>
<init-param>
<param-name>fruit1</param-name>
<param-value>Mango</param-value>
</init-param>
<init-param>
<param-name>fruit2</param-name>
<param-value>orange</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>aaa</servlet-name>
<url-pattern>/second</url-pattern>
</servlet-mapping>
</web-app>
//first.jsp
pageEncoding="ISO-8859-1"%>
<html>
<head>
</head>
<body>
<%
%>
</body>
</html>
//second.jsp
pageEncoding="ISO-8859-1"%>
<html>
<head>
</head>
<body>
<%
%>
</body>
</html>
//login.html
<html>
<body>
</form>
</body>
</html>
//loginAction.jsp
pageEncoding="ISO-8859-1"%>
<html>
<body>
<%!
String uname;
String upwd;
%>
<%
uname = request.getParameter("username");
upwd = request.getParameter("password");
%>
<jsp:forward page="success.jsp"/>
<%
else
%>
<jsp:include page="login.html"/>
<%
%>
</body>
</html>
//success.jsp
pageEncoding="ISO-8859-1" import="java.util.*"%>
<html>
<head>
</head>
<body>
%>
</body>
</html>
JSP Day-6
Jsp Actions :
//to configure the bean class
4. <jsp:include---->
5. <jsp:forward---->
6. <jsp:param---->
7. <jsp:params---->
7. <jsp:plugin---->
8. <jsp:fallback---->
//emp.html:
<html>
<body>
</form>
</body>
</html>
//main.jsp
<html>
<body>
String ename;
double esal;
%>
ename = request.getParameter("ename");
esal = Double.parseDouble(request.getParameter("esal"));
%>
</body>
</html>
//EmpBean.java
package com.tcs;
return eid;
this.eid = eid;
return ename;
this.ename = ename;
return esal;
this.esal = esal;
//AppletDemo.java
package com.tcs;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
msg1 = getParameter("message1");
msg2 = getParameter("message2");
//set the font size & style
g.setFont(f);
this.setBackground(Color.blue);
this.setForeground(Color.white);
//form.jsp
pageEncoding="ISO-8859-1"%>
<html>
<body>
<jsp:params>
</jsp:params>
</jsp:plugin>
</body>
</html>
ex-3:
<%@page import="java.util.*"%>
<jsp:declaration>
Date d = null;
<jsp:scriptlet>
d = new Date();
date = d.toString();
</jsp:scriptlet>
<html>
<body bgcolor="lightyellow">
</font></b></center></body>
</html>
//registrationform.html
<html>
<body bgcolor="lightgreen">
<form action="registration.jsp">
<pre>
<u>Registration Form</u>
</pre>
</form>
</body>
</html>
//existed.jsp:
<center><h1>User Existed</h1></center>
//success.jsp:
<center><h1>Registration Success</h1></center>
//failure.jsp:
<center><h1>Registration Failure</h1></center>
//registration.jsp:
<%@page import="java.sql.*"%>
<%!
String uname;
int uage;
String uaddr;
ResultSet rs;
static{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
st=con.createStatement();
catch(Exception e){
e.printStackTrace();
%>
<%
try{
uname = request.getParameter("uname");
uage = Integer.parseInt(request.getParameter("uage"));
uaddr = request.getParameter("uaddr");
if(b==true)
%>
<jsp:forward page="existed.jsp"/>
<%
else
if(rowCount == 1)
%>
<jsp:forward page="success.jsp"/>
<%
else
%>
<jsp:forward page="failure.jsp"/>
<%
catch(Exception e){
%>
<jsp:forward page="failure.jsp"/>
<%
e.printStackTrace();
%>
ex: before includeing the target file we can give inpiut to target file.
//main.jsp:
<body>
<jsp:include page="hello.jsp">
</jsp:include>
</body>
</html>
hello.jsp:
<%@page import="java.util.*"%>
<html>
<head>
<body>
welcome to Sravyainfotech<br>
</body>
</html>
JSP day-7
{ setPageContext()
setParent()
getPrarent()
doEndTag()
release()
}
setPageContext()
doEndTag()
release()
There are 2 possible return values from doStartTag() method.: talking about body
There are 2 possible return values from doEndTag() method. : remaining page
//hello.jsp
<mytags:hello>
hi ratan how r u
</mytags:hello>
<br>
//hello.tld
<taglib>
<jsp-version>2.1</jsp-version>
<tlib-version>1.0</tlib-version>
<tag>
<name>hello</name>
<tag-class>com.tcs.CustomTag</tag-class>
<body-content>jsp</body-content>
</tag>
</taglib>
//CustomTag.java
package com.tcs;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
@Override
return EVAL_PAGE;
@Override
try {
writer.println("<br>");
} catch (IOException e) {
e.printStackTrace();
return EVAL_BODY_INCLUDE;
@Override
return null;
@Override
}
@Override
this.context = context;
@Override
JSP day-8
EVAL_BODY_AGAIN
SKIP_BODY
//hello.jsp
<mytags:iterate times="10"><br>
Hi Ratan how r u
</mytags:iterate>
//hello.tld
<taglib>
<jsp-version>2.1</jsp-version>
<tlib-version>1.0</tlib-version>
<tag>
<name>iterate</name>
<tag-class>com.tcs.IterateTag</tag-class>
<body-content>jsp</body-content>
<attribute>
<name>times</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
//IterateTag.java
package com.tcs;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
this.times = times;
@Override
if(times>count)
{ count++;
return EVAL_BODY_AGAIN;
else
{ return SKIP_BODY;
@Override
return EVAL_PAGE;
}
@Override
return EVAL_BODY_INCLUDE;
ex2:
//hello.jsp
Hi Ratan how r u
</mytags:loop>
//hello.tld
<taglib>
<jsp-version>2.1</jsp-version>
<tlib-version>1.0</tlib-version>
<tag>
<name>loop</name>
<tag-class>com.tcs.Iteration</tag-class>
<body-content>jsp</body-content>
<attribute>
<name>start</name>
<required>true</required>
</attribute>
<attribute>
<name>end</name>
<required>true</required>
</attribute>
</tag>
</taglib>
//Iteration.java:
package com.tcs;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
this.start = start; }
this.end = end; }
@Override
if(end>start)
{ start++;
returnEVAL_BODY_AGAIN; }
else
{ returnEVAL_PAGE; }
@Override
return EVAL_BODY_INCLUDE;
ex-3:
//hello.jsp
<mytags:if condition='<%=10<20%>'>
<mytags:true>condition is true</mytags:true><br>
<mytags:false>condition is false</mytags:false><br>
</mytags:if>
//If.java
package com.tcs;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
this.condition = condition;
{ return condition;
@Override
return EVAL_BODY_INCLUDE;
//True.java
package com.tcs;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
@Override
If f = (If)getParent();
boolean b = f.getCondition();
if(b==true)
{ return EVAL_BODY_INCLUDE;
else {
return SKIP_BODY;
}
//False.java
package com.tcs;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
@Override
If f = (If)getParent();
boolean b = f.getCondition();
if(b==true)
{ return SKIP_BODY;
else
{ return EVAL_BODY_INCLUDE;
//hello.tld:
<taglib>
<jsp-version>2.1</jsp-version>
<tlib-version>1.0</tlib-version>
<tag>
<name>if</name>
<tag-class>com.tcs.If</tag-class>
<body-content>jsp</body-content>
<attribute>
<name>condition</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>true</name>
<tag-class>com.tcs.True</tag-class>
<body-content>jsp</body-content>
</tag>
<tag>
<name>false</name>
<tag-class>com.tcs.False</tag-class>
<body-content>jsp</body-content>
</tag>
</taglib>
ex1:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<br>
<br><br>
<c:out value="${a}"/>
</font></b></center>
<body>
<html>
ex-2:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<br>
a-----><c:out value="${a}"/>
<br><br>
a-----><c:out value="${a}"/>
</font></b></center>
<body>
<html>
ex-3:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<c:catch var="e">
<jsp:scriptlet>
java.util.Date d=null;
out.println(d.toString());
</jsp:scriptlet>
</c:catch>
<c:out value="${e}"/>
</font></b></center>
<body>
<html>
ex-4:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<c:if test="${a<b}">
condition is true
</c:if>
<br>
out of if
</font></b></center>
<body>
<html>
ex-5:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<c:choose>
<c:when test="${a==10}">
TEN
</c:when>
<c:when test="${a==15}">
FIFTEEN
</c:when>
<c:when test="${a==20}">
TWENTY
</c:when>
<c:otherwise>
</c:otherwise>
</c:choose>
</font></b></center>
<body>
<html>
ex-6:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<c:out value="${a}"/><br>
</c:forEach>
<%
String[] s={"A","B","C"};
request.setAttribute("s",s);
%>
<br>
<c:out value="${x}"/><br>
</c:forEach>
</font></b></center>
<body>
<html>
ex-7:
second.jsp:
<center><h1>This is second.jsp</h1></center>
core7.jsp:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
Start
<br>
<c:import url="second.jsp"/>
<br>
End
</font></b></center>
<body>
<html>
ex-8:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<c:redirect url="http://facebook.com"/>
</font></b></center>
<body>
<html>
SQL data :
ex-1:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
user="system" password="ratan"/>
</font></b></center>
</body>
</html>
ex 2:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
user="system" password="ratan"/>
</font></b></center>
</body>
</html>
ex 3:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
user="system" password="ratan"/>
<sql:param value="444"/>
<sql:param>anu</sql:param>
<sql:param value="40000"/>
</sql:update>
</font></b></center>
</body>
</html>
ex 4:
<html>
<body>
<center><b><font size="7">
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe" user="system" password="ratan"/>
<sql:update var="result">
<sql:param>500</sql:param>
<sql:param>5000</sql:param>
</sql:update>
</font></b></center></body>
</html>
ex-5:
<%@page isELIgnored="true"%>
<html>
<body>
<center><b><font size="7">
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe" user="system" password="ratan"/>
<tr>
<c:out value="${columnName}"/>
</font></b></center></td>
</c:forEach>
</tr>
<tr>
<c:forEach var="column" items="${row}">
<td><b><font size="5">
<c:out value="${column}"/>
</font></b></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</font></b></center>
</body>
</html>
ex: