Adv Java
Adv Java
*imp
JDBC API:
interface:
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
============================================================
interface.
Method Signature of getConnection():
syntax:
("db-url","username","password");
Diagrams:
==========================================================
*imp
===========================================================
*imp
JDBC statements:
on DB-Product.
[Link]
[Link]
[Link]
Dt : 9/5/2023
*imp
JDBC statements:
on DB-Product.
[Link]
[Link]
[Link]
[Link]:
syntax:
Statement stm = [Link]();
(i)executeQuery()
(ii)executeUpdate()
(i)executeQuery():
syntax:
ResultSet rs = [Link]("select-query");
(ii)executeUpdate():
syntax:
int k = [Link]("NonSelect-query");
-----------------------------------------------------------
*imp
Click "Launch"
step-6 : Type the JDBC code to retrieve data from the table:EMP52
Program : [Link]
package test;
import [Link].*;
public class DBCon1 {
public static void main(String[] args) {
try
{
[Link]("[Link]");
//Loading driver
while([Link]())
{
[Link]([Link](1)+"\t"+
[Link](2)+"\t"+[Link](3)+"\t"+
[Link](4));
}//end of loop
[Link]();
//closing connection
}//end of try
catch(Exception e)
{
[Link]();
}
}
}
o/p:
========================================================
Assignment:
(pcode,pname,pprice,pqty)
===========================================================
Dt : 10/5/2023
============================================================
*imp
into DB-table(Emp52):
Program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon2 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try
{
[Link]("Enter the empId:");
String id = [Link]();
[Link]("Enter the empName:");
String name = [Link]();
[Link]("Enter the empDesg:");
String desg = [Link]();
[Link]("Enter the empSal:");
int sal = [Link]();
int k = [Link]
("insert into Emp52
values('"+id+"','"+name+"','"+desg+"',"+sal+")");
if(k>0)
{
[Link]("Record inserted
Successfully..");
}
[Link]();
}//end of try
catch(InputMismatchException ime)
{
[Link]("Invalid input...");
}
catch(SQLIntegrityConstraintViolationException sicve)
{
[Link]("Employee details already
available...");
}
catch(SQLException cnfe)
{
[Link]();
}
}//end of try with resource
}
}
o/p:
B130
Enter the empName:
Ram
SE
16000
===============================================================
Assignment:
=============================================================
*imp
[Link]:
IN-parameters
syntax:
PreparedStatement ps = [Link]("query-structure");
=================================================================
Dt : 11/5/2023
Table : BookDetails52
(bcode,bname,bauthor,bprice,bqty)
primary key(bcode));
based on User-Choice:
[Link]
[Link]
Program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon3 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try {
Connection con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
//Creating Connection
PreparedStatement ps1 = [Link]
("insert into BookDetails52 values(?,?,?,?,?)");
//Compilation
PreparedStatement ps2 = [Link]
("select * from BookDetails52");
//Compilation
while(true) {
[Link]("****Choice****");
[Link]("\[Link]"
+ "\n\[Link]"
+ "\n\[Link]");
[Link]("Enter the Choice:");
int choice = [Link]([Link]());
switch(choice) {
case 1:
[Link]("Enter the BookCode:");
String bC = [Link]();
[Link]("Enter the BookName:");
String bN = [Link]();
[Link]("Enter the
BookAuthor:");
String bA = [Link]();
[Link]("Enter the
BookPrice:");
float bP = [Link]([Link]());
[Link]("Enter the BookQty:");
int bQ = [Link]([Link]());
int k = [Link]();//Execution
if(k>0) {
[Link]
("BookDetails inserted
Successfully...");
}
break;
case 2:
ResultSet rs = [Link]();
//Execution
[Link]("****Book-
Details****");
while([Link]()) {
[Link]([Link](1)+"\t"
+[Link](2)+"\t"+
[Link](3)+"\t"+
[Link](4)+"\t"
+[Link](5));
}//end of loop
break;
case 3:
[Link]("Operation on DB
Stopped...");
[Link](0);
default:
[Link]("Invalid Choice..");
}//end of switch
}//end of loop
}catch(Exception e) {
[Link]();
}
}//end of try with resource
}
}
o/p:
****Choice****
[Link]
[Link]
[Link]
A101
B-Swamy
1200
12
****Choice****
[Link]
[Link]
[Link]
A123
CoreJ
XYZ
1700
17
****Choice****
[Link]
[Link]
[Link]
****Book-Details****
****Choice****
[Link]
[Link]
[Link]
A345
AdvJ
PQR
1900
19
****Choice****
[Link]
[Link]
[Link]
2
****Book-Details****
****Choice****
[Link]
[Link]
[Link]
Operation on DB Stopped...
==========================================================
Assignment:
DB table : BankCustomer52
(accno,custname,balance,acctype)
(PreparedStatement)
[Link]
[Link]
=========================================================
Dt : 12/5/2023
package test;
import [Link].*;
import [Link].*;
try {
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
//Creating Connection
//Compilation
//Compilation
while(true) {
[Link]("****Choice****");
[Link]("\[Link]"
+ "\n\[Link]"
+ "\n\[Link]"
+ "\n\[Link](Price/Qty)"
+ "\n\[Link]"
+ "\n\[Link]");
switch(choice) {
case 1:
String bN = [Link]();
String bA = [Link]();
float bP = [Link]([Link]());
int bQ = [Link]([Link]());
[Link](1, bC);
[Link](2, bN);
[Link](3, bA);
[Link](4, bP);
[Link](5, bQ);
int k = [Link]();//Execution
if(k>0) {
[Link]
break;
case 2:
ResultSet rs = [Link]();
//Execution
[Link]("****Book-Details****");
while([Link]()) {
[Link]([Link](1)+"\t"
+[Link](2)+"\t"+
[Link](3)+"\t"+
[Link](4)+"\t"
+[Link](5));
}//end of loop
break;
case 3:
[Link](1, code);
if([Link]()) {
[Link]([Link](1)+"\t"
+[Link](2)+"\t"+
[Link](3)+"\t"+
[Link](4)+"\t"
+[Link](5));
}else {
[Link]("Invalid bookCode...");
break;
case 4:
[Link](1, code2);
if([Link]()) {
[Link](1, nPrice);
[Link](2, nQty);
[Link](3, code2);
int k2 = [Link]();
if(k2>0) {
}else {
[Link]("Invalid BookCode..");
break;
case 5:
[Link](1, code3);
if([Link]()) {
[Link](1, code3);
int k3 = [Link]();
if(k3>0) {
[Link]("BookDetails deleted
Successfully..");
}else {
[Link]("Invalid BookCode...");
break;
case 6:
[Link]("Operation on DB Stopped...");
[Link](0);
default:
[Link]("Invalid Choice..");
}//end of switch
}//end of loop
}catch(Exception e) {
[Link]();
=========================================================
Diagram:
========================================================
Dt : 13/5/2023
faq:
(i)Statement
(ii)PreparedStatement
Multiple times.
Note:
============================================================
Assignment-1:
(uname,pword,fname,lname,addr,mid,phno)
Operations:
[Link]
[Link]
[Link]
[Link]:
choice
[Link]
[Link]
[Link]
[Link]:
choice:
[Link] Profile
[Link] Profile(addr,mailid,phno)
[Link](Exit)
[Link]
[Link]
[Link]
=============================================================
Assignment-1:
Student52(rollNo,name,branch,totmarks,per,grade)
StuMarks52(rollNo,sub1,sub2,sub3,sub4,sub5,sub6)
Operations
[Link]
[Link]
[Link]
[Link]
[Link]:
=>Calculate totM,per,grade
[Link]
[Link]
[Link]
===========================================================
Note:
[Link]
Oracle10 - [Link]
Oracle11 - [Link]
oracle12 - [Link],[Link]
([Link])
MySQL - [Link]
PostgreSQL - [Link]
SQLite - [Link]
=============================================================
Dt : 15/5/2023
faq:
define ResultSet?
(i)Using Statement:
ResultSet rs = [Link]("select-query");
(ii)Using PreparedStatemnent:
ResultSet rs = [Link]();
-------------------------------------------------------
top-of-the-table-data to Bottom-of-table-data.
Ex:
*imp
two directions,which means down the table data and upward the
table data.
PreparedStatement ps = [Link]("query-S",type,mode);
Type:
Mode:
Note:
decrement.
---------------------------------------------------------
Ex-program :
[Link](MainClass)
package test;
import [Link].*;
public class DBCon4 {
public static void main(String[] args) {
try {
Connection con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
//Creating Connection
Statement stm = [Link]
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link]
("select * from BookDetails52");
[Link]("****Table data in reverse*****");
[Link]();//Cursor pointing after last row
while([Link]()) {
[Link]([Link](1)+"\t"
+[Link](2)+"\t"
+[Link](3)+"\t"
+[Link](4)+"\t"
+[Link](5));
}//end of loop
PreparedStatement ps = [Link]
("select * from BookDetails52",1004,1007);
ResultSet rs2 = [Link]();
[Link]("****Row-3****");
[Link](3);
[Link]([Link](1)+"\t"
+[Link](2)+"\t"
+[Link](3)+"\t"
+[Link](4)+"\t"
+[Link](5));
[Link]("****relative(-2)****");
[Link](-2);
[Link]([Link](1)+"\t"
+[Link](2)+"\t"
+[Link](3)+"\t"
+[Link](4)+"\t"
+[Link](5));
[Link]("****relative(+1)****");
[Link](+1);
[Link]([Link](1)+"\t"
+[Link](2)+"\t"
+[Link](3)+"\t"
+[Link](4)+"\t"
+[Link](5));
}catch(Exception e) {
[Link]();
}
}
}
o/p:
****relative(-2)****
****relative(+1)****
==========================================================
Assignment:
[Link] Normal
[Link] Reverse
[Link]
========================================================
Dt : 16/5/2023
*imp
(a)addBatch()
(b)executeBatch()
(c)clearBatch()
(a)addBatch():
Method Signature:
public abstract void addBatch([Link])
throws [Link];
(b)executeBatch():
Method Signature:
(c)clearBatch():
Method Signature:
Note:
--------------------------------------------------------------
Program : [Link]
package test;
import [Link].*;
import [Link].*;
try(s){
try {
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
[Link]("====Delete employee====");
String id = [Link]();
[Link]
for(int i=0;i<[Link];i++) {
[Link]("Executed Successfully...");
[Link]();
[Link]();
}catch(Exception e) {[Link]();}
}//end of try
}
}
o/p:
****Enter BookDetails****
A312
HB-JPA
PQR
1800
18
====Delete employee====
A111
Executed Successfully...
Executed Successfully...
============================================================
Table : Product52
package test;
import [Link].*;
import [Link].*;
try(s;){
try {
//Creating Connection
PreparedStatement ps = [Link]
int n = [Link]([Link]());
for(int i=1;i<=n;i++) {
[Link]("****Details of Product-"+i+"****");
[Link](1, code);
[Link](2, name);
[Link](3, price);
[Link](4, qty);
}//end of loop
for(int i=0;i<[Link];i++) {
[Link]("Executed Successfully...");
[Link]();
[Link]();
}catch(Exception e) {[Link]();}
Program : [Link](MainClass)
o/p:
****Details of Product-1****
A102
Mou
1200
12
****Details of Product-2****
A204
CDR
1200
****Details of Product-3****
A312
KB
1400
14
Executed Successfully...
Executed Successfully...
Executed Successfully...
=======================================================
Note:
DB tables at-a-time.
the values.
Batch Processing.
update processing"
============================================================
faq:
=============================================================
Dt : 17/5/2023
*imp
define Transaction?
A - Atomicity
C - Consistency
I - Isolation
D - Durability
A - Atomicity:
known as Atomicity.
C - Consistency:
Consistency
I - Isolation:
as Isolation.
D - Durability:
--------------------------------------------------------
define Transaction Management?
Management:
(a)setAutoCommit()
(b)getAutoCommit()
(c)commit()
(d)rollback()
(e)setSavepoint()
(f)releaseSavepoint()
(a)setAutoCommit():
to "false" or "true"
syntax:
[Link](false);
(b)getAutoCommit():
operation.
syntax:
boolean k = [Link]();
(c)commit():
database permanently.
syntax:
[Link]();
(d)rollback():
state.
syntax:
[Link](sp);
(e)setSavepoint():
rollback-operation.
syntax:
Savepoint sp = [Link]();
(f)releaseSavepoint():
syntax:
[Link](sp);
----------------------------------------------------------
Ex-program:
Table : Bank52
(accno,name,bal,acctype)
accNo:6123456 to accNo:313131
SubT1 : Subtract 3000/- from accNo : 6123456
Program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon7 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try {
Connection con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
[Link]("Status of AutoCommit :
"+[Link]());
[Link](false);
[Link]("Status of AutoCommit :
"+[Link]());
PreparedStatement ps1 = [Link]
("select * from Bank52 where
accNo=?");
PreparedStatement ps2 = [Link]
("update Bank52 set bal=bal+? where
accNo=?");
Savepoint sp = [Link]();
[Link]("Enter the Home AccNo:");
long hAccNo = [Link]();
[Link](1, hAccNo);
ResultSet rs1 = [Link]();
if([Link]()) {
float bl = [Link](3);
[Link]("Enter beneficiery
AccNo:");
long bAccNo = [Link]();
[Link](1, bAccNo);
ResultSet rs2 = [Link]();
if([Link]()) {
[Link]("Enter the amt to be
Transferred:");
float amt = [Link]();
if(amt<=bl) {
[Link](1,-amt);
[Link](2, hAccNo);
int i = [Link]();//Updated
in buffer
[Link](1, amt);
[Link](2, bAccNo);
int j = [Link]();//Updated
in buffer
if(i==1 && j==1) {
[Link]("Transaction
Successfull...");
[Link]();//Update the database
}else {
[Link]("Transaction
Failed...");
[Link](sp);
}
}else {
[Link]("Insufficient
fund...");
}
}else {
[Link]("Invalid
bAccNo...");
}
}else {
[Link]("Invalid
homeAccNo...");
}
}catch(Exception e) {[Link]();}
}//end of try with resource
}
}
o/p:
6123456
313131
3000
Transaction Successfull...
=========================================================
============================================================
Dt : 18/5/2023
===============================================================
Assignment:
DBtable : TransLogTab52
(haccno,baccno,amt,dateTime)
===============================================================
Assignmet:
Construct JDBC Application to display transsaction details based
on hAccNo.
============================================================
*imp
process.
Diagram:
Ex-Application:
[Link]
package test;
import [Link].*;
import [Link].*;
public class ConnectionPooling {
public String dbUrl,uName,pWord;
public ConnectionPooling(String dbUrl,String uName,
String pWord) {
[Link]=dbUrl;
[Link]=uName;
[Link]=pWord;
}
public Vector<Connection> v = new Vector<Connection>();
public void createConnections() {
try {
while([Link]()<5) {
[Link]("Pool is not full....");
Connection con = [Link]
(dbUrl,uName,pWord);
[Link](con);
[Link](con);
}//end of loop
if([Link]()==5) {
[Link]("Pool is full....");
}
}catch(Exception e) {[Link]();}
}//end of method
[Link](MainClass)
package test;
public class DBCon8 {
public static void main(String[] args) {
ConnectionPooling cp = new ConnectionPooling
("jdbc:oracle:thin:@localhost:1521:xe",
"system","manager");
[Link]();
}
}
o/p:
[Link].T4CConnection@3159c4b8
[Link].T4CConnection@6328d34a
[Link].T4CConnection@145eaa29
[Link].T4CConnection@2d2e5f00
[Link].T4CConnection@4c40b76e
Pool is full....
=========================================================
Dt : 19/5/2023
Note:
Hierarchy of Vector<E>:
Diagram:
Program:
[Link](Modified)
package test;
import [Link].*;
import [Link].*;
String pWord) {
[Link]=dbUrl;
[Link]=uName;
[Link]=pWord;
}
//Instance reference variable(Tightly Coupled reference)
//Instance method
try {
while([Link]()<5) {
(dbUrl,uName,pWord);
[Link](con);
}//end of loop
if([Link]()==5) {
[Link]("Pool is full....");
}catch(Exception e) {[Link]();}
}//end of method
return con;
}//end of method
}//end of method
[Link](MainClass)(Modified)
package test;
import [Link].*;
public class DBCon8 {
public static void main(String[] args) {
ConnectionPooling cp = new ConnectionPooling
("jdbc:oracle:thin:@localhost:1521:xe",
"system","manager");
[Link]();//method call
[Link]("*****User-1*****");
Connection cn1 = [Link]();
[Link]("Con at user-1 : "+cn1);
[Link]("Size of pool : "+[Link]());
try {
PreparedStatement ps1 = [Link]("Select *
from Product52");
ResultSet rs1 = [Link]();
while([Link]()) {
[Link]([Link](1)+"\t"+
[Link](2)+"\t"+[Link](3)+
"\t"+[Link](4));
}//end of loop
}catch(Exception e) {[Link]();}
[Link]("****User-2****");
Connection cn2 = [Link]();
[Link]("Con at user-2 : "+cn2);
[Link]("Size of pool : "+[Link]());
try {
PreparedStatement ps2 = [Link]
("Select * from Emp52");
ResultSet rs2 = [Link]();
while([Link]()) {
[Link]([Link](1)+
"\t"+[Link](2)+
"\t"+[Link](3)+
"\t"+[Link](4));
}//end of loop
}catch(Exception e) {[Link]();}
[Link]("*****User-1****");
[Link](cn1);
[Link]("Size of pool : "+[Link]());
[Link]("*****User-2****");
[Link](cn2);
[Link]("Size of pool : "+[Link]());
[Link]("-----Display Connections----");
[Link]((k)->
{
[Link](k);
});
}
}
o/p:
[Link].T4CConnection@525f1e4e
[Link].T4CConnection@75f9eccc
[Link].T4CConnection@67e2d983
[Link].T4CConnection@5d47c63f
Pool is full....
*****User-1*****
Size of pool : 4
A312 KB 1400.0 14
****User-2****
Size of pool : 3
*****User-1****
Size of pool : 4
*****User-2****
Size of pool : 5
-----Display Connections----
[Link].T4CConnection@75f9eccc
[Link].T4CConnection@67e2d983
[Link].T4CConnection@5d47c63f
[Link].T4CConnection@3159c4b8
[Link].T4CConnection@525f1e4e
==========================================================
Dt : 20/5/2023
*imp
[Link]:
product.
syntax:
-------------------------------------------------
Diagram:
faq:
define Procedure?
structure of procedure:
(para_list) is
begin
query1;
query2;
...
end;
define Function?
structure of Function:
begin
query1;
query2;
....
return var;
end;
========================================================
*imp
CustDetails52(CustId,fname,lname)
CustAddress52(CustId,hno,sname,city,pincode)
CustContact52(CustId,mid,phno)
primary key(CustId));
begin
end;
Customer-data
Program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon9 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try {
[Link]("Enter the CustId:");
String cId = [Link]();
[Link]("Enter the CustFirstName:");
String fName = [Link]();
[Link]("Enter the CustLastName:");
String lName = [Link]();
[Link]("Enter the hNo:");
String hNo = [Link]();
[Link]("Enter the StreetName:");
String sName = [Link]();
[Link]("Enter the City:");
String city = [Link]();
[Link]("Enter the PinCode:");
int pinCode = [Link]([Link]());
[Link]("Enter the MailId:");
String mId = [Link]();
[Link]("Enter the PhoneNo:");
long phNo = [Link]([Link]());
[Link]();
[Link]("Procedure executed
Successfully...");
[Link]("CustData updated....");
}catch(Exception e) {[Link]();}
}//end of try
}
}
o/p:
E102
Raj
Kumar
12-34/h
SR Nagar
Hyd
612345
r@[Link]
CustData updated....
==========================================
Assignment:
EmpDetails52(eid,ename,edesg)
EmpAddress52(eid,hno,sname,city,pincode)
EmpContact52(eid,mid,phno)
EmpSalary52(eid,bsal,hra,da,totSal)
============================================================
Dt : 23/5/2023
==============================================================
*imp
Types of Precedures:
[Link]-Parameter Procedures
[Link]-Parameter Procedures
[Link]-Parameter Procedures:
Ex:
above programs
[Link]-Parameter Procedures:
=>The procedures which take the data from database tables and
custId.
begin
end;
Procedure.
Program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon10 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try {
[Link]("Enter the CustId:");
String cId = [Link]();
Connection con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
CallableStatement cs = [Link]
("{call CustRetrieve52(?,?,?,?,?,?,?,?,?)}");
[Link](1, cId);
[Link](2, [Link]);
[Link](3, [Link]);
[Link](4, [Link]);
[Link](5, [Link]);
[Link](6, [Link]);
[Link](7, [Link]);
[Link](8, [Link]);
[Link](9, [Link]);
[Link]();
[Link]("CId:"+cId);
[Link]("FName:"+[Link](2));
[Link]("LName:"+[Link](3));
[Link]("HNo:"+[Link](4));
[Link]("SName:"+[Link](5));
[Link]("City:"+[Link](6));
[Link]("PinCode:"+[Link](7));
[Link]("MID:"+[Link](8));
[Link]("PhNo:"+[Link](9));
}catch(Exception e) {
// [Link]();
//[Link]([Link]());
[Link]([Link]());
}
}//end of try with resource
}
}
o/p:
E102
CId:E102
FName:Raj
LName:Kumar
HNo:12-34/h
SName:SR Nagar
City:Hyd
PinCode:612345
MID:r@[Link]
PhNo:9898981234
-----------------------------------------------------
Diagram:
======================================================
faq:
Ex:
[Link](2, [Link]);
[Link](3, [Link]);
Note:
sql-types
Ex:
....
===========================================================
Assignment:
based on empId
Procedure
==========================================================
Dt : 24/5/2023
*imp
on custId.
begin
return pno;
end;
Program : [Link]
package test;
import [Link].*;
import [Link].*;
try {
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
CallableStatement cs = [Link]
("{call ?:=Retrievephno52(?)}");
[Link](1, [Link]);
[Link](2, cId);
[Link]();
[Link]("CustId:"+cId);
[Link]("PhNO:"+[Link](1));
}catch(Exception e) {[Link]();}
o/P:
E102
CustId:E102
PhNO:9898981234
Diagram:
==========================================================
Assignment:
==========================================================
*imp
Types of Streams:
[Link] Stream
[Link] Stream
[Link] Stream:
[Link] Stream :
---------------------------------------------------------
(a)BLOB
(b)CLOB
(a)BLOB:
(b)CLOB:
===========================================================
Ex-program:
DB Table : StreamTab52(id,mfile)
create table StreamTab52(id varchar2(10),mfile BLOB,
primary key(id));
Program : [Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
try(s;){
try {
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
PreparedStatement ps = [Link]
String id = [Link]();
[Link](1, id);
[Link]("Enter fPath&fName(Source):");
int k = [Link]();
if(k>0) {
}
}catch(Exception e) {[Link]();}
o/p:
M101
Enter fPath&fName(Source):
C:\Images\IMG_4917.JPG
============================================================
Ex-program:
on id.
program : [Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
try(s;){
try {
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
PreparedStatement ps = [Link]
[Link](1, id);
ResultSet rs = [Link]();
if([Link]()) {
Blob b = [Link](2);
[Link]("Enter fPath&fName(destination):");
[Link](by);
[Link]();
}else {
[Link]("Invalid Id...");
}catch(Exception e) {[Link]();}
o/p:
M101
Enter fPath&fName(destination):
D:\Images\[Link]
=============================================================
Dt : 25/5/2023
faq:
define FileInputStream?
data.
syntax:
faq:
define FileOutputStream?
used to create a new file and opens the file to write binary stream
data.
syntax:
faq:
define "File"?
or not,...
syntax:
--------------------------------------------------------
Diagram:
==========================================================
*imp
define 'RowSet'?
(a)JDBCRowSet
(b)CachedRowSet
=>WebRowSet
(i)FilteredRowSet
(ii)JoinRowSet
Hierarchy of RowSet:
-----------------------------------------------------
faq:
(i)JdbcRowSet
(ii)CachedRowSet
(i)JdbcRowSet:
is active.
(ii)CachedRowSet:
is Dis-Connected automatically.
--------------------------------------------------------------
Dt : 26/5/2023
Note:
condition.
=>JoinRowSet will hold the data joined from more than one
ResultSet
=========================================================
*imp
define RowSetFactory?
implementations of RowSet:
(a)createJdbcRowSet()
(b)createCachedRowSet()
(c)createWebRowSet()
(d)createFilteredRowSet()
(e)createJoinRowSet()
(a)createJdbcRowSet():
=>This method is used to create the implementation object of
'JdbcRowSet'.
Method Signature:
throws [Link];
(b)createCachedRowSet():
'CachedRowSet'.
Method Signature:
throws [Link];
(c)createWebRowSet():
'WebRowSet'.
Method Signature:
throws [Link];
(d)createFilteredRowSet():
'FilteredRowSet'.
Method Signature:
(e)createJoinRowSet():
'JoinRowSet'.
Method Signature:
------------------------------------------------------
Note:
throws [Link];
([Link], [Link])
throws [Link];
===================================================================
Ex-program : [Link]
package test;
import [Link].*;
import [Link].*;
public class DBCon14 {
public static void main(String[] args) {
Scanner s = new Scanner([Link]);
try(s;){
try {
RowSetFactory rsf = [Link]();
[Link]("****Choice****");
[Link]("\[Link]"
+ "\n\[Link]");
[Link]("Enter the Choice:");
switch([Link]()) {
case 1:
JdbcRowSet jrs = [Link]();
[Link]("jdbc:oracle:thin:@localhost:1521:xe");
[Link]("system");
[Link]("manager");
[Link]("select * from BookDetails");
[Link]();
[Link]("====BookDetails=====");
while([Link]()) {
[Link]([Link](1)+
"\t"+[Link](2)+
"\t"+[Link](3)+
"\t"+[Link](4)+
"\t"+[Link](5));
}//end of loop
break;
case 2:
CachedRowSet crs = [Link]();
[Link]("jdbc:oracle:thin:@localhost:1521:xe");
[Link]("system");
[Link]("manager");
[Link]("select * from BookDetails");
[Link]();
[Link]("=====Display in reverse====");
[Link]();
while([Link]()) {
[Link]([Link](1)+
"\t"+[Link](2)+
"\t"+[Link](3)+
"\t"+[Link](4)+
"\t"+[Link](5));
}//end of loop
break;
default:
[Link]("Invalid Choice...");
}//end of switch
}catch(Exception e) {[Link]();}
}//End of try with resource
}
}
o/p:
****Choice****
[Link]
[Link]
=====Display in reverse====
========================================================
Note:
faq:
as "Meta data".
[Link]
[Link]
[Link]
[Link]
[Link]:
syntax:
[Link]:
=>ParameterMetaData is an interface from [Link] package and
syntax:
[Link]:
syntax:
[Link]:
syntax:
==============================================================
Dt : 27/5/2023
Program : [Link]
package test;
import [Link].*;
import [Link].*;
try(s;)
try
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
[Link]("*****DatabaseMetadata****");
[Link]("URL = "+[Link]());
PreparedStatement ps = [Link]
[Link]("*****ParameterMetaData*****");
String id = [Link]();
[Link](1, id);
[Link](2, name);
[Link](3, price);
[Link](4, qty);
int k = [Link]();
if(k>0) {
[Link]("****ResuleStMetaData****");
ResultSet rs = [Link]();
while([Link]()) {
[Link]([Link](1)+"\t"
+[Link](2)+
"\t"+[Link](3));
}//end of loop
for(int i=1;i<=[Link]();i++) {
[Link]("Col-"+i+" : "
+[Link](i)+" - "
+[Link](i));
}//end of loop
[Link]();
catch(SQLIntegrityConstraintViolationException sicve)
catch(NumberFormatException nfe)
[Link]("Invalid input...");
catch(Exception e)
[Link]();
o/p:
*****DatabaseMetadata****
URL = jdbc:oracle:thin:@localhost:1521:xe
driver version = 11
*****ParameterMetaData*****
parameter count = 4
****ResuleStMetaData****
A107 HB 700.0
Col Count = 3
=====================================================
faq:
syntax:
Class c = [Link]("Class_name");
(or)
[Link]("Class_name");
========================================================
faq:
Hierarchy of JDBC-statements:
===========================================================
faq:
form of objects.
============================================================
faq:
define AutoCloseable?
statement.
==============================================================
Dt : 29/5/2023
CoreJava Objects:
[Link]-Objects
[Link] Objects
[Link] Objects
[Link]<E> Objects
[Link]<K,V> Objects
[Link]<E> Objects
JDBC Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
(a)JdbcRowSet Object
(b)CachedRowSet Object
=>WebRowSet
(i)FilteredRowSet Object
(ii)JoinRowSet Object
[Link] Objects
(i)DatabaseMetaData Object
(ii)ParameterMetaData Object
(iii)ResultSetMetaData Object
(iv)RowSetMetaData Object
============================================================
*imp
Servlet Programming:
faq:
define Servlet?
Diagram:
faq:
define Server?
Diagram:
========================================================
faq:
define Application?
is known as Application.
Types of Applications:
[Link] Applications
[Link] Applications
[Link] Applications
[Link] Applications
[Link] Applications:
(i)CUI Applications
(ii)GUI Applications
(i)CUI Applications:
(ii)GUI Applications:
(b)Swing
Diagram:
Note:
==========================================================
*imp
[Link] Applications:
Applications.
Applications:
(i)JDBC
(ii)Servlet
(iii)JSP
Note:
=>In WebApplications,
=====================================================
*imp
[Link] Applications:
Distributed Applications.
====================================================
*imp
[Link] Applications:
========================================================
Dt : 30/5/2023
Note:
environmnet.
program.
------------------------------------------------------------
[Link] SE
[Link] EE
[Link] ME
[Link] SE:
*imp
[Link] EE:
Applications.
[Link] ME:
Applications
============================================================
faq:
define WebContainer?
(i)Servlet Container
(ii)JSP Container
Diagram:
------------------------------------------------------------
*imp
Types of Servers:
(a)WebServers
(b)Application Servers
(a)WebServer:
html pages.
applications.
(b)Application Server:
enterprise applications.
=>Weblogic, JBoss.
------------------------------------------------------------------
Dt : 2/6/2023
*imp
Note:
(i)Servlet container
(ii)JSP Container
Link : [Link]
[Link]
[Link]
(click Next)
Password : nit
(click Next)
C:\Tomcat 9.0\bin
[Link]
C:\Tomcat 9.0\bin
============================================================
*imp
Servlet API:
development
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]():
Method Signature:
throws [Link];
[Link]():
method.
Method Signature:
[Link]) throws
[Link], [Link];
[Link]():
destroy() method.
Method Signature:
[Link]():
details.
Method Signature:
[Link]():
Method Signature:
-------------------------------------------------------
Dt : 3/6/2023
Note:
Diagram:
=========================================================
*imp
step-1 : Open IDE Eclispe,while opening name the WorkSpace and click
"Launch"
directory"->Click "Finish".
Program : [Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@WebServlet("/first")
//NoCode
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]("<br>UserName : "+name);
[Link]("<br>MailID : "+mailId);
"Finish"
[Link]
========================================================
Dt : 5/6/2023
[Link]
==========================================================
*imp
ServletContext:
Server.
=>This ServletContext Object is loaded with server information.
*imp
ServletConfig:
execution.
*imp
ServletRequest:
execution
HTML form
*imp
ServletResponse:
execution.
sending as response.
faq:
syntax:
PrintWriter pw = [Link]();
faq:
syntax:
[Link]("text/htmm");
faq:
syntax:
===========================================================
Assignment-1:
(code,name,price,qty)
Assignment-2:
(code,name,author,price,qty)
Note:
=================================================================
Dt : 6/6/2023
Assignment-1:
(code,name,price,qty)
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="post" action="dis">
<table>
<tr>
<td>ProdCode</td>
<td><input type="text"
name="code"><br></td>
</tr>
<tr>
<td>ProdName</td>
<td><input type="text"
name="name"><br></td>
</tr>
<tr>
<td>ProdPrice</td>
<td><input type="text"
name="price"><br></td>
</tr>
<tr>
<td>ProdQty</td>
<td><input type="text"
name="qty"><br></td>
</tr>
<tr>
<td><input type="submit"
value="Display"></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@WebServlet("/dis")
//NoCode
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
String cd = [Link]("code");
String nm = [Link]("name");
float pr = [Link]([Link]("price"));
int qt = [Link]([Link]("qty"));
[Link]("====ProductDeatils====");
[Link]("<br>Code:"+cd);
[Link]("<br>Name:"+nm);
[Link]("<br>Price:"+pr);
[Link]("<br>Qty:"+qt);
//NoCode
return [Link]();
return "DisplayServlet";
[Link]
*imp
Hierarchy of Servlet-API:
================================================================
Note:
interface.
then we have to construct body for service() method and init() and
initialization - init()
===========================================================
*imp
(i)servlet to servlet
(ii)servlet to HTML
(iii)servlet to JSP
communications:
(a)forward()
(b)include()
(a)forward():
which means ServletProgram1 will take the request and forwards the
[Link])
Diagram:
(b)include():
which means ServletProgram1 will take the request and provide the
ServletProgram2.
[Link])
Diagram:
========================================================
Dt : 7/6/2023
Note:
syntax:
RequestDispatcher rd =
[Link]("url-patter/HTML/JSP");
---------------------------------------------------------
Ex-Application:(Demonstrating RequestDispatcher)
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="choice" method="post">
Enter the Value1:<input type="text" name="v1"><br>
Enter the Value2:<input type="text" name="v2"><br>
<input type="submit" value="Add" name="s1">
<input type="submit" value="Sub" name="s1">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/choice")
throws ServletException,IOException{
String s1 = [Link]("s1");
if([Link]("Add")) {
RequestDispatcher rd =
[Link]("ad");
[Link](req, res);
}else {
RequestDispatcher rd =
[Link]("sb");
[Link](req, res);
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/ad")
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
try
int v1 = [Link]([Link]("v1"));
int v2 = [Link]([Link]("v2"));
int v3 = v1+v2;
[Link]("Sum : "+v3+"<br>");
catch(Exception e)
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/sb")
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
try
int v1 = [Link]([Link]("v1"));
int v2 = [Link]([Link]("v2"));
int v3 = v1-v2;
[Link]("Sub : "+v3+"<br>");
catch(Exception e)
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
===================================================
Note:
=>Only one "ServletContext" object is created for WebApplication,
=======================================================
Assignment:
=>Mul
=>Div
=>ModDiv
=>Greater
=>Smaller
========================================================
Dt : 8/6/2023
*imp
=>The classes which are declared with the following rules are
interface.
Variables
or 0-parameter constructor
methods.
-------------------------------------------------------
Note:
----------------------------------------------------------
faq:
=>The methods which are used to get the data from the Objects are
known as Getter-methods.
faq:
=>The methods which are used to set the data to the Objects are
known as Setter-methods.
Coding rule:
=>Every variable in class will have its own Setter and Getter
methods.
==============================================================
faq:
=>DAO stands for "Data Access Object" and which is separate layer
ralated logics.
Diagram:
===============================================================
Note:
and DB Product,the "DB Jar file" must be copied into "lib" folder
of WEB-INF
=============================================================
Ex-Application:
Operations.
DB Table : Employee52(id,name,desg,bsal,totsal)
Primary Key : id
primary key(id));
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="[Link]">AddEmployee</a>
<a href="view">ViewAllEmployees</a>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="add" method="post">
Employee Id:<input type="text" name="id"><br>
Employee Name:<input type="text" name="name"><br>
Employee Desg:<input type="text" name="desg"><br>
Employee BSal:<input type="text" name="bsal"><br>
<input type="submit" value="AddEmployee">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class EmployeeBean implements Serializable{
private String id,name,desg;
private int bSal;
private float totSal;
public EmployeeBean() {}
public String getId() {
return id;
}
public void setId(String id) {
[Link] = id;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public String getDesg() {
return desg;
}
public void setDesg(String desg) {
[Link] = desg;
}
public int getbSal() {
return bSal;
}
public void setbSal(int bSal) {
[Link] = bSal;
}
public float getTotSal() {
return totSal;
}
public void setTotSal(float totSal) {
[Link] = totSal;
}
[Link]
package test;
import [Link].*;
public class DBConnection {
private static Connection con = null;
private DBConnection() {}
static
{
try {
[Link]("[Link]");
con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
}catch(Exception e) {[Link]();}
}//end of block
public static Connection getCon() {
return con;
}
}
[Link]
package test;
import [Link].*;
public class InsertEmployeeDAO {
public int k=0;
public int insert(EmployeeBean eb) {
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
("insert into Employee52
values(?,?,?,?,?)");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
[Link](5, [Link]());
k = [Link]();
}catch(Exception e) {[Link]();}
return k;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/add")
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]([Link]("id"));
[Link]([Link]("name"));
[Link]([Link]("desg"));
[Link](bSal);
[Link](totSal);
if(k>0) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
-----------------------------------------------------
Dt : 9/6/2023
[Link]
package test;
import [Link].*;
import [Link].*;
public ArrayList<EmployeeBean> al =
new ArrayList<EmployeeBean>();
{
try
PreparedStatement ps = [Link]
ResultSet rs = [Link]();
while([Link]())
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
}//end of loop
catch(Exception e)
[Link]();
return al;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/view")
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
ArrayList<EmployeeBean> al =
new ViewEmployeesDAO().retrieve();
if([Link]()==0) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
[Link]((k)->
EmployeeBean eb = (EmployeeBean)k;
[Link]([Link]()+"  "+
[Link]()+"  "+
[Link]()+"  "+
[Link]()+"  "+
[Link]()+
"<a href='edit'>Edit</a><a
href='delete'>Delete</a><br>");
});
[Link]("<a href='[Link]'>Back</a>");
}//end of else
}
Layout:
=======================================================
Assignment-1:
=>AddProduct
=>ViewAllProducts
DB Table : Product52
Assignment-2 :
=>AddBookDetails
=>ViewAllBookDetails
DB Table : BookDetails52
======================================================
*imp
ServletContext:
Server.
=>This ServletContext object is loaded with Server-information.
ServletContext object.
syntax:
in ServletContext object.
syntax:
<web-app>
<context-param>
<param-name>name</param-name>
<param-value>name</param-value>
</context-param>
</web-app>
-------------------------------------------------------------
Dt : 10/6/2023
Ex-Application:(Demonstrating ServletContext)
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="dis" method="post">
UserName:<input type="text" name="uname"><br>
<input type="submit" value="Display">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/dis")
throws ServletException,IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]("Welcome : "+uName);
[Link]("<br>****ServletContext****");
[Link]("<br>ServerInfo:"+[Link]());
Enumeration<String> e = [Link]();
while([Link]())
[Link]("<br>"+str+":"+[Link](str));
}//end of loop
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<context-param>
<param-name>x</param-name>
<param-value>1000</param-value>
</context-param>
<context-param>
<param-name>y</param-name>
<param-value>2000</param-value>
</context-param>
<context-param>
<param-name>z</param-name>
<param-value>3000</param-value>
</context-param>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
o/p:
Welcome : Alex
****ServletContext****
ServerInfo:Apache Tomcat/9.0.67
x:1000
y:2000
z:3000
=========================================================
syntax:
syntax:
Enumeration<String> e = [Link]();
===============================================================
Note:
===============================================================
Dt : 13/6/2023
*imp
"attribute" in ServletProgramming:
"HttpSession" object.
(a)setAttribute()
(b)getAttribute()
(c)getAttributeNames()
(d)removeAttribute()
(a)setAttribute():
Method Signature:
([Link],[Link]);
(b)getAttribute():
Method Signature:
(c)getAttributeNames():
Method Signature:
getAttributeNames();
(d)removeAttribute():
Objects.
Method Signature:
---------------------------------------------------------
*imp
Scope of "attribues":
"attributes".
(ii)"attributes" in ServletRequest Object will have Request Scope
==============================================================
faq:
define request?
Types of requests:
[Link] request
[Link] request
[Link] request:
Animation
...
</form>
Method Signature:
[Link])throws
[Link],[Link];
-------------------------------------------------------------
[Link] request:
=>The request which is generated to get the data from the Server
4kb or 8kb
in address-bar of WebBrowser
...
</form>
<form action="url">
...
</form>
<a href="view">ViewAllEmployee</a>
[Link])throws
[Link],[Link];
========================================================
*imp
define Session?
as Session Tracking.
in Servlet Programming:
[Link]
[Link]
[Link] re-write
---------------------------------------------------------------
Dt : 14/6/2023
[Link]:
Types of Cookies:
(i)Persistent Cookie
(ii)NonPersistent Cookie
(i)Persistent Cookie:
---------------------------------------------------------
Note:
"[Link]" class.
public [Link]
([Link], [Link]);
Hierarchy of Cookie:
=============================================================
Ex-Application:
process.
DBTable : UserReg52(uname,pword,fname,lname,addr,mid,phno)
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="log" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
<input type="submit" value="Login">
<a href="[Link]">NewUser?</a>
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="reg" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
FirstName:<input type="text" name="fname"><br>
LastName:<input type="text" name="lname"><br>
Address:<input type="text" name="addr"><br>
MailId:<input type="text" name="mid"><br>
PhoneNo:<input type="text" name="phno"><br>
<input type="submit" value="Register">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class UserBean implements Serializable{
private String uName,pWord,fName,lName,addr,mId;
private long phNo;
public UserBean() {}
public String getuName() {
return uName;
}
public void setuName(String uName) {
[Link] = uName;
}
public String getpWord() {
return pWord;
}
public void setpWord(String pWord) {
[Link] = pWord;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
[Link] = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
[Link] = lName;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
[Link] = addr;
}
public String getmId() {
return mId;
}
public void setmId(String mId) {
[Link] = mId;
}
public long getPhNo() {
return phNo;
}
public void setPhNo(long phNo) {
[Link] = phNo;
}
[Link]
package test;
import [Link].*;
public class DBConnection {
private static Connection con = null;
private DBConnection() {}
static
{
try {
[Link]("[Link]");
con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
}catch(Exception e) {[Link]();}
}//end of block
public static Connection getCon() {
return con;
}
}
[Link]
package test;
import [Link].*;
public class RegisterDAO {
public int k=0;
public int register(UserBean ub) {
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
("insert into UserReg52
values(?,?,?,?,?,?,?)");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
[Link](5, [Link]());
[Link](6, [Link]());
[Link](7, [Link]());
k = [Link]();
}catch(Exception e) {[Link]();}
return k;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/reg")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]([Link]("uname"));
[Link]([Link]("pword"));
[Link]([Link]("fname"));
[Link]([Link]("lname"));
[Link]([Link]("addr"));
[Link]([Link]("mid"));
[Link]([Link]([Link]("phno")));
int k = new RegisterDAO().register(ub);
if(k>0) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
----------------------------------------------
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="view">ViewProfile</a>
<a href="logout">Logout</a>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
[Link](1, [Link]("uname"));
[Link](2, [Link]("pword"));
ResultSet rs = [Link]();
if([Link]()) {
ub = new UserBean();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
[Link]([Link](6));
[Link]([Link](7));
}catch(Exception e) {[Link]();}
return ub;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/log")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(ub==null) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
[Link]("ub", ub);
[Link](ck);
//Serialization process
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
=====================================================
Dt : 15/6/2023
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/view")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(c==null) {
[Link]("Session expired..<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
UserBean ub = (UserBean)[Link]("ub");
[Link]([Link]()+"   "
+[Link]()+"   "
+[Link]()+"   "
+[Link]()+"   "
+[Link]()+"   "
+"<a href='edit'>EditProfile</a>"
+"   "
+"<a href='logout'>Logout</a>");
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/logout")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(c==null) {
[Link]("Session Expired...<br>");
}else {
[Link]("ub");
c[0].setMaxAge(0);
[Link](c[0]);
}//end of else
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}
=========================================================
Dt : 16/6/2023
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/edit")
PrintWriter pw = [Link]();
[Link]("text/html");
if(c==null) {
[Link]("Session Expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
UserBean ub = (UserBean)[Link]("ub");
[Link]("</form>");
[Link]
package test;
import [Link].*;
public class UpdateProfileDAO {
public int k=0;
public int update(UserBean ub) {
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
("update UserReg52 set addr=?,mid=?,phno=? where
uname=? and pword=?");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
[Link](5, [Link]());
k = [Link]();
}catch(Exception e) {[Link]();}
return k;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/update")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(c==null) {
[Link]("Session expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
UserBean ub = (UserBean)[Link]("ub");
[Link]([Link]("addr"));
[Link]([Link]("mid"));
[Link]([Link]([Link]("phno")));
if(k>0) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
========================================================
Summary:
=======================================================
Dt : 17/6/2023
*imp
[Link]:
([Link], [Link]);
([Link]);
getAttributeNames();
([Link], [Link]);
([Link]);
getServletContext();
getSessionContext();
----------------------------------------------------
=>we use getSession() method from "HttpServletRequest"
getSession(boolean);
-------------------------------------------------------------
DBTables :
Table : UserTab52
Table : AdminTab52
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="[Link]">UserLogin</a>
<a href="[Link]">AdminLogin</a>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="admin" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
<input type="submit" value="Login">
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="user" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
<input type="submit" value="Login">
<a href="[Link]">NewUser?</a>
</form>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="[Link]">AddProduct</a>
<a href="view">ViewAllProducts</a>
<a href="logout">Logout</a>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="add" method="post">
ProductCode:<input type="text" name="code"><br>
ProductName:<input type="text" name="name"><br>
ProductPrice:<input type="text" name="price"><br>
ProductQty:<input type="text" name="qty"><br>
<input type="submit" value="AddProduct">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
public class DBConnection {
private static Connection con = null;
private DBConnection() {}
static
{
try {
[Link]("[Link]");
con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
}catch(Exception e) {[Link]();}
}//end of block
public static Connection getCon() {
return con;
}
}
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class AdminBean implements Serializable{
private String uName,pWord,fName,lName,addr,mId;
private long phNo;
public AdminBean() {}
public String getuName() {
return uName;
}
public void setuName(String uName) {
[Link] = uName;
}
public String getpWord() {
return pWord;
}
public void setpWord(String pWord) {
[Link] = pWord;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
[Link] = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
[Link] = lName;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
[Link] = addr;
}
public String getmId() {
return mId;
}
public void setmId(String mId) {
[Link] = mId;
}
public long getPhNo() {
return phNo;
}
public void setPhNo(long phNo) {
[Link] = phNo;
}
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class ProductBean implements Serializable{
private String code,name;
private float price;
private int qty;
public ProductBean() {}
public String getCode() {
return code;
}
public void setCode(String code) {
[Link] = code;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
[Link] = price;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
[Link] = qty;
}
[Link]
package test;
import [Link].*;
import [Link].*;
public class AdminLoginDAO {
try {
PreparedStatement ps = [Link]
[Link](1, [Link]("uname"));
[Link](2, [Link]("pword"));
ResultSet rs = [Link]();
if([Link]()) {
ab = new AdminBean();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
[Link]([Link](6));
[Link]([Link](7));
}catch(Exception e) {[Link]();}
return ab;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/admin")
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(ab==null) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
[Link]("ab", ab);
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/logout")
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("Session expired...<br>");
}else {
[Link]("ab");
[Link]();//session destroyed
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
========================================================
Dt : 22/6/2023
[Link]
package test;
import [Link].*;
public class AddProductDAO {
public int k=0;
public int add(ProductBean pb) {
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
("insert into Product52
values(?,?,?,?)");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
k = [Link]();
}catch(Exception e) {[Link]();}
return k;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/add")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("Session expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
AdminBean ab = (AdminBean)[Link]("ab");
[Link]([Link]("code"));
[Link]([Link]("name"));
[Link]([Link]([Link]("price")));
[Link]([Link]([Link]("qty")));
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
if(k>0) {
}
[Link]
package test;
import [Link].*;
import [Link].*;
try {
PreparedStatement ps = [Link]
ResultSet rs = [Link]();
while([Link]()) {
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
}//end of loop
}catch(Exception e) {[Link]();}
return al;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/view")
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("Session expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
AdminBean ab = (AdminBean)[Link]("ab");
[Link]("al", al);
if([Link]()==0) {
}else {
[Link]((k)->
ProductBean pb = (ProductBean)k;
[Link]([Link]()+"   "
+[Link]()+"   "
+[Link]()+"   "
+[Link]()+"   "
+"<a
href='edit?pcode="+[Link]()+"'>Edit</a>"
+"   "
+"<a
href='delete?pcode="+[Link]()+"'>Delete</a><br>");
});
[Link]("<a href='[Link]'>Back</a>"
+"   "
+"<a href='logout'>Logout</a>");
==========================================================
Dt : 23/6/2023
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/edit")
@SuppressWarnings("unchecked")
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("Session Expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
ArrayList<ProductBean> al =
(ArrayList<ProductBean>)[Link]("al");
[Link]((k)->
if([Link]([Link]())) {
[Link]("</form>");
});
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/update")
@SuppressWarnings("unchecked")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("Session Expired...<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
AdminBean ab = (AdminBean)[Link]("ab");
ArrayList<ProductBean> al =
(ArrayList<ProductBean>)[Link]("al");
[Link]((k)->{
if([Link]([Link]())) {
[Link]([Link]([Link]("pprice")));
[Link]([Link]([Link]("pqty")));
});
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
[Link]
package test;
import [Link].*;
public class UpdateProductDAO {
public int z=0;
public int update(ProductBean pb) {
try {
Connection con = [Link]();
PreparedStatement ps = [Link]
("update Product52 set price=?,qty=? where code=?");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
z = [Link]();
}catch(Exception e) {[Link]();}
return z;
}
}
========================================================
[Link] re-write:
syntax:
url-pattern?para1=value¶2=value¶3=value&...
? - This symbol is separator b/w url-pattern and para-values
[Link]
q=gmail
&rlz=1C1YTUH_enIN1024IN1024
&oq=
&aqs=chrome.0.35i39i362j46i39i199i362i465j35i39i362l2j46i39i199i362i465j35i39i362j46i39i
199i362i465j35i39i362.2392573929j0j15
&sourceid=chrome
&ie=UTF-8
[Link]
pcode=A001
----------------------------------------------------------------
end-users.
syntax:
....
</form>
================================================================
Dt : 24/6/2023
dependent.
=>HttpSession will track the user from the Server and which is
Server dependent.
faq:
(i)getSession()
(ii)getSession(false)
(iii)getSession(true)
(i)getSession():
(ii)getSession(false):
(iii)getSession(true):
===========================================================
Note:
Sub-Tracking techniques.
======================================================
Summary of Objects:
CoreJava:
[Link]-Objects
[Link] Objects
[Link]-Objects
[Link]<E> Objects
[Link]<K,V> Objects
[Link]<E> Objects
JDBC Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
Servlet Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
================================================================
faq:
define Serialization?
faq:
the form of binary Stream and we can move on the N/W from one
----------------------------------------------------------
two types:
(a)Serializable Objects
(b)NonSerializable Objects
(a)Serializable Objects:
=>The objects which are generated from the classes and the
Ex:
Cookie Object
Bean Object
JCF Objects
(b)NonSerializable Objects:
=>The Object which are generated from the classes and the classes
Ex:
JDBC Objects
============================================================
faq:
===============================================================
Dt : 27/6/2023
*imp
Advantage of Filters:
(i)Converion process
(ii)Logging process
(iii)Compression process
(iv)Encryption process
(v)DeCryption Process
(vi)Input Validations
Diagram:
---------------------------------------------------------
[Link]
[Link]
[Link]
[Link]:
throws [Link];
[Link], [Link])
[Link]:
execution.
request.
[Link];
-----------------------------------------------------------------
Ex-Aplication:
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="log" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
<input type="submit" value="Login">
<a href="[Link]">NewUser?</a>
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class UserBean implements Serializable{
private String uName,pWord,fName,lName,addr,mId;
private long phNo;
public UserBean() {}
public String getuName() {
return uName;
}
public void setuName(String uName) {
[Link] = uName;
}
public String getpWord() {
return pWord;
}
public void setpWord(String pWord) {
[Link] = pWord;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
[Link] = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
[Link] = lName;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
[Link] = addr;
}
public String getmId() {
return mId;
}
public void setmId(String mId) {
[Link] = mId;
}
public long getPhNo() {
return phNo;
}
public void setPhNo(long phNo) {
[Link] = phNo;
}
[Link]
package test;
import [Link].*;
public class DBConnection {
private static Connection con = null;
private DBConnection() {}
static
{
try {
[Link]("[Link]");
con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
}catch(Exception e) {[Link]();}
}//end of block
public static Connection getCon() {
return con;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
try {
PreparedStatement ps = [Link]
[Link](1, [Link]("uname"));
[Link](2, [Link]("pword"));
ResultSet rs = [Link]();
if([Link]()) {
ub = new UserBean();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
[Link]([Link](6));
[Link]([Link](7));
}catch(Exception e) {[Link]();}
return ub;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@WebFilter("/log")
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
if(ub==null) {
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}else {
[Link]("fName", [Link]());
[Link]("lName", [Link]());
[Link]("addr", [Link]());
[Link]("mid", [Link]());
[Link]("phno",[Link]([Link]()));
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/log")
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
[Link](fName+"   "
+lName+"   "
+addr+"   "
+mId+"   "
+phNo+"<br>");
RequestDispatcher rd =
[Link]("[Link]");
[Link](req, res);
}
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
-------------------------------------------------------------
Dt : 28/6/2023
[Link]:
syntax:
<web-app>
...
<filter>
<filter-name>name</filter-name>
<filter-class>class</filter-class>
<init-param>
<param-name>name</param-name>
<param-value>value</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>name</filter-name>
<url-pattern>/url</url-pattern>
</filter-mapping>
...
</web-app>
--------------------------------------------------
Ex-Application:
Layout:
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<filter>
<filter-name>DisplayFilter</filter-name>
<filter-class>[Link]</filter-class>
<init-param>
<param-name>a</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>b</param-name>
<param-value>200</param-value>
</init-param>
<init-param>
<param-name>c</param-name>
<param-value>300</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DisplayFilter</filter-name>
<url-pattern>/dis</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="dis" method="post">
UserName:<input type="text" name="uname"><br>
<input type="submit" value="Display">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@Override
[Link]=fcf;
@Override
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]("Welcome UserName:"+uName+"<br>");
[Link]("****FilterConfig****<br>");
[Link]("FilterName:"+[Link]()+"<br>");
Enumeration<String> e = [Link]();
while([Link]()) {
String el = [Link]();
}//end of loop
======================================================
Note:
========================================================
*imp
define Event?
=>The action which is performed on Servlet-Objects is known as
define Listener?
Diagram:
--------------------------------------------------------
[Link]
[Link]
[Link]
[Link]:
Listener : ServletContextListener
Methods :
public void contextInitialized([Link]);
Methods :
([Link]);
([Link]);
([Link]);
-----------------------------------------------------
[Link]:
Listener : ServletRequestListerner
Methods :
Methods :
([Link]);
([Link]);
([Link]);
------------------------------------------------------
[Link]:
Methods :
Methods :
([Link]);
([Link]);
([Link]);
=============================================================
Dt : 29/6/2023
Note:
and ServletContextAttributeListener.
[Link]
package test;
import [Link].*;
import [Link].*;
@WebListener
ServletContextAttributeListener{
@Override
@Override
[Link]("Context destroyed...");
@Override
(ServletContextAttributeEvent scae) {
@Override
(ServletContextAttributeEvent scae) {
---------------------------------------------------------------
Note:
ServletRequestAttributeListener
[Link]
package test;
import [Link].*;
import [Link].*;
@WebListener
ServletRequestAttributeListener{
@Override
[Link]("request initialized...");
@Override
[Link]("request destroyed...");
(ServletRequestAttributeEvent srae) {
(ServletRequestAttributeEvent srae) {
-------------------------------------------------------------
Note:
HttpSessionAttributeListener
[Link]
package test;
import [Link].*;
import [Link].*;
@WebListener
HttpSessionAttributeListener{
@Override
[Link]("Session Created...");
@Override
[Link]("Session Destroyed...");
@Override
(HttpSessionBindingEvent hsbe) {
@Override
(HttpSessionBindingEvent hsbe) {
=============================================================
Note:
============================================================
Note:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
============================================================
dt : 30/6/2023
*imp
<web-app>
<context-param>
<param-name>name</param-name>
<param-value>value</param-value>
</context-param>
<listener>
<listener-class>class</listener-class>
</listener>
<filter>
<filter-name>name</filter-name>
<filter-class>class</filter-class>
<init-param>
<param-name>name</param-name>
<param-value>value</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>name</filter-name>
<url-pattern>/url</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>name</servlet-name>
<servlet-class>class</servlet-class>
<init-param>
<param-name>name</param-name>
<param-value>value</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>name</servlet-name>
<url-pattern>/url</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>file_name</welcome-file>
</welcome-file-list>
</web-app>
==========================================================
faq:
Types of Listeners:
=>Listeners in Servlet-programming are categorized into three
types:
[Link] Listener
[Link] Listener
[Link] Listener
[Link] Listener:
as Application Listener.
[Link] Listener:
as Request Listerner.
[Link] Listener:
Listener.
=============================================================
*imp
Annotation.
(i)@Override
(ii)@SuppressWarnings
(i)@Override:
(ii)@SuppressWarnings
------------------------------------------------------
ServletProgramming:
(i)@WebServlet
(ii)@WebFilter
(iii)@WebListener
(i)@WebServlet:
(ii)@WebFilter:
(iii)@WebListener :
============================================================
*imp(faq)
Servlet Collaboration:
(i)RequestDispatcher
(ii)sendRedirect()
(i)RequestDispatcher:
(ii)sendRedirect():
or different Servers.
Application : WebApp1
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="first" method="post">
UserName:<input type="text" name="uname"><br>
MailId:<input type="text" name="mid"><br>
<input type="submit" value="Dispaly">
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/first")
@Override
IOException{
[Link]
("[Link]
+"&mid="+mId);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
Application : WebApp2
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/second")
@Override
PrintWriter pw = [Link]();
[Link]("text/html");
[Link]("****SecondServlet****<br>");
[Link]("UserName:"+uName+"<br>");
[Link]("MailId:"+mId);
========================================================
[Link]
==========================================================
Dt : 1/7/2023
*imp
Servlet-Life-Cycle:
[Link] process
[Link] process
[Link] process
[Link] process
[Link] process:
[Link] process:
Note:
methods:
GenericServlet:
init()
service()
destroy()
HttpServlet:
init()
service()/doPost()/doGet()
destroy()
Filter:
init()
doFilter()
destroy()
[Link] process:
Note:
only once.
handling process.
Note:
multiple users.
[Link] process:
==========================================================
Ex-Application:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="dis" method="post">
UserName:<input type="text" name="uname"><br>
<input type="submit" value="Display">
</form>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/dis")
public int x;
public int y;
public Display()
x++;
y++;
@Override
x++;
y++;
@Override
IOException{
PrintWriter pw = [Link]();
[Link]("text/html");
@Override
x=100;
y=200;
}
===========================================================
*imp
Execution URL:
===========================================================
faq:
(i)JAR
(ii)WAR
(iii)EAR
(i)JAR:
class files.
(ii)WAR:
(iii)EAR:
Summary:
(Spring,WebServices)
=================================================================
Dt : 3/7/2023
*imp
JSP Programming:(Unit-3)
=>JSP Stands for 'Java Server Page' and which is response from
WebApplication.
=>JSP programs are combination of both HTML code and Java Code.
programs:
[Link] tags
=>Scriptlet tag
=>Expression tag
=>Declarative tag
[Link] tags
=>page
=>include
=>taglib
[Link] tags
=>jsp:include
=>jsp:forward
=>jsp:param
=>jsp:useBean
=>jsp:setProperty
=>jsp:getProperty
[Link] tags:
(a)Scriptlet tag
(b)Expression tag
(c)Declarative tag
(a)Scriptlet tag:
syntax:
(b)Expression tag:
syntax:
(c)Declarative tag:
programs.
syntax:
=======================================================================
[Link] tags:
(a)page
(b)include
(c)taglib
(a)page:
=>'page' directive tag specifies the translator to add the related
syntax:
exp:
List of attributes:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
-----------------------------------------------------
(b)include:
syntax:
Exp:
(c)taglib:
JSP page and which is used part of EL(Expression Lang) and JSTL
syntax:
===============================================
Ex : JSP Application
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="[Link]" method="post">
Enter the Value:<input type="text" name="v"><br>
<input type="submit" value="Factorial">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
errorPage="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!
int fact;
int factorial(int n)
{
fact=1;
for(int i=n;i>=1;i--)
{
fact=fact*i;
}
return fact;
}
%>
<%
int n = [Link]([Link]("v"));
int res = factorial(n);
[Link]("Factorial:"+res+"<br>");
%>
<%@ include file="[Link]"%>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
isErrorPage="true"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
[Link]("Enter only Integer values...<br>");
%>
<%= exception %>
<br>
<%@ include file="[Link]"%>
</body>
</html>
==================================================
application - [Link]
config - [Link]
request - [Link]
response - [Link]
out - [Link]
session - [Link]
exception - [Link]
page - [Link]
pageContext - [Link]
=============================================================
[Link] tags:
Note:
------------------------------------------------------
JSP:
1.<jsp:include>
2.<jsp:forward>
3.<jsp:param>
4.<jsp:useBean>
5.<jsp:setProperty>
6.<jsp:getProperty>
=============================================================
1.<jsp:include> :
syntax:
<jsp:include attributes>
</jsp:include>
*imp
<jsp:include page="/[Link]"/>
<jsp:include page="<%=mypath%>"/>
2.<jsp:forward>:
sntax:
<jsp:forward attributes>
</jsp:forward>
Exp:
<jsp:forward page="/[Link]"/>
<jsp:forward page="<%=mypath%>"/>
3.<jsp:param>:
syntax:
====================================================
4.<jsp:useBean>:
syntax:
<jsp:useBean attributes>
</jsp:useBean>
(a)id
(b)scope
(c)class
(d)beanName
(e)type
(a)id:
(b)scope:
created or located.
(i)page scope : within the JSP page,until the page sends response.
(ii)request scope : JSP page processing the same request until a JSP sends response.
*imp
(c)class :
bean instance.
(d)beanName :
(e)type :
5.<jsp:setProperty>:
Types of attributes:
(a)name
(b)property
(c)value
(d)param
(a)name:
(b)property:
(c)value:
=>The value attribute takes the value that has to be set to the
(d)param:
6.<jsp:getProperty>:
by using the bean's getter method and writes the value to the
current JspWriter.
Types of attributes:
(a)name
(b)property
(a)name:
(b)property:
=>which gets the value of a bean property and invokes the getter
-------------------------------------
Syntax:
<jsp:plugin attributes>
</jsp:plugin>
and this action tag must be used as a child tag with the
Syntax:
<jsp:fallback>
</jsp:fallback>
Syntax:
<jsp:params>
===================================================================
Dt : 4/7/2023
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="[Link]" method="post">
Enter the Value1:<input type="text" name="v1"><br>
Enter the Value2:<input type="text" name="v2"><br>
<input type="submit" value="Add" name="s1">
<input type="submit" value="Sub" name="s1">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String s1 = [Link]("s1");
if([Link]("Add")){
%>
<jsp:forward page="[Link]">
<jsp:param value="<%=200 %>" name="nm"/>
</jsp:forward>
<%
}else{
%>
<jsp:forward page="[Link]">
<jsp:param value="500" name="nm"/>
</jsp:forward>
<%
}
%>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
errorPage="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
int v1 = [Link]([Link]("v1"));
int v2 = [Link]([Link]("v2"));
String nm = [Link]("nm");
int v3 = v1+v2;
[Link]("Param-Value:"+nm+"<br>");
[Link]("Sum:"+v3+"<br>");
%>
<jsp:include page="[Link]"/>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
errorPage="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
int v1 = [Link]([Link]("v1"));
int v2 = [Link]([Link]("v2"));
String nm = [Link]("nm");
int v3 = v1-v2;
[Link]("Param-Value:"+nm+"<br>");
[Link]("Sub:"+v3+"<br>");
%>
<jsp:include page="[Link]"/>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
isErrorPage="true"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
[Link]("Enter only Integer values..<br>");
%>
<%= exception %>
<br>
<jsp:include page="[Link]"/>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
=======================================================
getProperty)
Layout:
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class ProductBean implements Serializable{
private String code,name;
private float price;
private int qty;
public ProductBean() {}
public String getCode() {
return code;
}
public void setCode(String code) {
[Link] = code;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
[Link] = price;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
[Link] = qty;
}
}
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="[Link]" method="post">
ProdCode:<input type="text" name="code"><br>
ProdName:<input type="text" name="name"><br>
ProdPrice:<input type="text" name="price"><br>
ProdQty:<input type="text" name="qty"><br>
<input type="submit" value="LoadProduct">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
import="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="ob" class="[Link]" scope="session"/>
<jsp:setProperty property="code" param="code" name="ob"/>
<jsp:setProperty property="name" param="name" name="ob"/>
<jsp:setProperty property="price" param="price" name="ob"/>
<jsp:setProperty property="qty" param="qty" name="ob"/>
<%
[Link]("Producr details loaded to Bean-Object..<br>");
%>
<a href="[Link]">ViewDetailsFromBean</a>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
import="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="ob" type="[Link]" scope="session"/>
ProductCode:<jsp:getProperty property="code" name="ob"/><br>
ProductName:<jsp:getProperty property="name" name="ob"/><br>
ProductPrice:<jsp:getProperty property="price" name="ob"/><br>
ProductQty:<jsp:getProperty property="qty" name="ob"/><br>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
========================================================
Dt : 5/7/2023
faq:
JSP Life-Cycle:
[Link] process
[Link] process
[Link] process
[Link] process
[Link] process
[Link] process
Diagram:
[Link] process:
as Translation process.
[Link] process:
[Link] process:
Loading process.
[Link] process:
Life-Cycle methods:
(i)_jspInit()
(ii)_jspService()
(iii)_jspDestroy()
[Link] process:
[Link] process:
==========================================================
*imp
MVC Architecture:
Diagram:
Controller(C):
=>Controller will accept the request from the end-user and controls
external services.
View(V):
=============================================================
*imp
1. Model-1 Architecture
2. Model-2 Architecture
Dt : 6/7/2023
1. Model-1 Architecture:
Diagram:
Limitations of the Model-1 Architecture:
Exp:
JSP_App1
JSP_App2
JSP_App3
===========================================================
2. Model-2 Architecture:
Diagram:
designed by JSP.
----------------------------------------------------
CoreJava:
[Link]-Objects
[Link] Objects
[Link]-Objects
[Link]<E> Objects
[Link]<K,V> Objects
[Link]<E> Objects
JDBC Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
Servlet Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
[Link] Object
JSP Objects:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
=========================================================
Project_Name : JSP_MVC
DBTables :
Table : UserTab52
'v@[Link]',9898981234);
Table : AdminTab52
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="[Link]">UserLogin</a>
<a href="[Link]">AdminLogin</a>
</body>
</html>
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="user" method="post">
UserName:<input type="text" name="uname"><br>
Password:<input type="password" name="pword"><br>
<input type="submit" value="Login">
<a href="[Link]">NewUser?</a>
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
public class DBConnection {
private static Connection con = null;
private DBConnection() {}
static
{
try {
[Link]("[Link]");
con = [Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","manager");
}catch(Exception e) {[Link]();}
}//end of block
public static Connection getCon() {
return con;
}
}
[Link]
package test;
import [Link].*;;
@SuppressWarnings("serial")
public class UserBean implements Serializable{
private String uName,pWord,fName,lName,addr,mId;
private long phNo;
public UserBean() {}
public String getuName() {
return uName;
}
public void setuName(String uName) {
[Link] = uName;
}
public String getpWord() {
return pWord;
}
public void setpWord(String pWord) {
[Link] = pWord;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
[Link] = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
[Link] = lName;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
[Link] = addr;
}
public String getmId() {
return mId;
}
public void setmId(String mId) {
[Link] = mId;
}
public long getPhNo() {
return phNo;
}
public void setPhNo(long phNo) {
[Link] = phNo;
}
[Link]
package test;
import [Link].*;
import [Link].*;
public class UserLoginDAO {
try {
PreparedStatement ps = [Link]
[Link](1, [Link]("uname"));
[Link](2, [Link]("pword"));
ResultSet rs = [Link]();
if([Link]()) {
ub = new UserBean();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
[Link]([Link](6));
[Link]([Link](7));
}catch(Exception e) {[Link]();}
return ub;
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/user")
IOException{
if(ub==null) {
[Link]("[Link]").forward(req, res);
}else {
HttpSession hs = [Link]();
[Link]("ub", ub);
[Link]("[Link]").forward(req, res);
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
import="[Link]"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
UserBean ub = (UserBean)[Link]("ub");
[Link]("Welcome User "+[Link]()+"<br>");
%>
<a href="view">ViewProducts</a>
<a href="logout">Logout</a>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String msg = (String)[Link]("msg");
[Link](msg+"<br>");
%>
<a href="[Link]">UserLogin</a>
<a href="[Link]">AdminLogin</a>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
=====================================================
Dt : 7/7/2023
[Link]
package test;
import [Link].*;
@SuppressWarnings("serial")
public class ProductBean implements Serializable{
private String code,name;
private float price;
private int qty;
public ProductBean() {}
public String getCode() {
return code;
}
public void setCode(String code) {
[Link] = code;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
[Link] = price;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
[Link] = qty;
}
[Link]
package test;
import [Link].*;
import [Link].*;
try {
PreparedStatement ps = [Link]
ResultSet rs = [Link]();
while([Link]()) {
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
}//end of loop
}catch(Exception e) {[Link]();}
return al;
}
}
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/view")
@Override
IOException{
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("[Link]").forward(req, res);
}else {
ArrayList<ProductBean> al =
new ViewProductsDAO().retrieve();
[Link]("al", al);
[Link]("[Link]").forward(req, res);
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
import="[Link].*,test.*"%>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
UserBean ub = (UserBean)[Link]("ub");
ArrayList<ProductBean> al =
(ArrayList<ProductBean>)[Link]("al");
[Link]("page of "+[Link]()+"<br>");
if([Link]()==0){
[Link]("Products not available...<br>");
}else{
Iterator<ProductBean> it = [Link]();
%>
<table>
<tr>
<th>CODE</th>
<th>NAME</th>
<th>PRICE</th>
<th>QTY</th>
</tr>
<%
while([Link]()){
ProductBean pb = (ProductBean)[Link]();
%>
<tr>
<td><%=[Link]() %></td>
<td><%=[Link]() %></td>
<td><%=[Link]() %></td>
<td><%=[Link]() %></td>
<td><a href="buy?code=<%=[Link]()%>">Buy</a></td>
</tr>
<%
}
%>
</table>
<a href="logout">Logout</a>
<%
}
%>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/logout")
@Override
IOException{
HttpSession hs = [Link](false);
if(hs==null) {
[Link]("msg","Session expired...<br>");
}else {
[Link]("ub");
[Link]("al");
[Link]();//session destroyed
[Link]("[Link]").forward(req, res);
==========================================================
*imp
request,session,application,etc..
Note:
syntax of EL:
$(expression)
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
values
of values
session,...
===============================================================
CoreJava Objects:
[Link] objects
(i)Byte Object
(ii)Short Object
(iii)Integer object
(iv)Long Object
(v)Float Object
(vi)Double Object
(vii)Character object
(viii)Boolean Object
[Link] Objects
(i)String Object
(ii)StringBuffer object
(iii)StringBuilder object
[Link] Objects
(ii)String Array
(iii)WrapperClass Array
(iv)Object Array
(v)Jagged Array
[Link]<E> Objects
(a)Set<E>
(i)HashSet<E> object
(ii)LinkedHashSet<E> Object
(iii)TreeSet<E> Object
(b)List<E>
(i)ArrayList<E> Object
(ii)Vector<E> Object
|->Stack<E> Object
(iii)LinkedList<E> Object
(c)Queue<E>
(i)PriorityQueue<E> Object
|->Deque<E>
(ii)ArrayDeque<E> Object
(iii)LinkedList<E> Object
[Link]<K,V> Objects
(i)HashMap<K,V> Object
(ii)LinkedHashMap<K,V> Object
(iii)TreeMap<K,V> Object
(iv)Hashtable<K,V> Object
[Link]<E> objects
------------------------------------
Utility Classes:
(i)[Link]
(ii)[Link]
(iii)[Link]
(iV)[Link]
(v)[Link]
---------------------------------------------
Cursor Objects:
(i)Iterator<E>
(ii)ListIterator<E>
(iii)Enumeration<E>
(iV)Spliterator<T>
===============================================
JDBC Objects:
[Link] Object
[Link] Object
[Link] Object
[Link] object
[Link] object
[Link] object
[Link] object
[Link] Object
(i)JdbcRowSet
(ii)CachedRowSet
=>WebRowSet
=>FilteredRowSet
=>JoinRowSer
[Link]
------------
Servlet Objects:
[Link] object
[Link] Object
[Link] object
[Link] object
[Link] object
[Link] object
[Link] Object
JSP objects:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
----------
JSP EL objects:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
--------------------------
Note:
========================================================
==============================================================
Dt : 10/7/2023
development.
Advantages of JSTL:
(i)Fast Development
(ii)Code Reusability
(1)Core Tags
(2)Function Tags
(3)Formatting Tags
(4)XML Tags
(5)SQL Tags
Note:
---------------------------------------------
(1)Core Tags:
syntax:
prefix="c" %>
The following are the List of JSTL Core Tags:
<%=...%> tag.
in the body.
*imp
supplied delimeters.
context-relative URLs.
-----------------------------------------------------
Ex-1:
Layout:
[Link]
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1">
<title>Insert title here</title>
</head> <body>
<form method="post" action="[Link]">
Enter the String:<input type="text" name="str"><br>
<input type="submit" value="Display">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="[Link]
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<c:set var="n" value="${[Link]}" />
<c:forEach var="j" begin="1" end="5">
<c:out value="${n}"/><p>
</c:forEach>
<c:forTokens items="${[Link]}" delims=" " var="name">
<c:out value="${name}"/><p>
</c:forTokens>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
---------------------------------------------------
Ex-2:
Layout:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="dis" method="post">
Enter the name:<input type="text" name="name"><br>
<input type="submit" value="Display">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO- 8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c"
uri="[Link] %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% [Link]("fName","Raju"); %>
<c:set var="name" value="${[Link]} "/>
WELCOME : <c:out value="${name}"/><br>
<c:set var="a" value="${applicationScope.a}" />
<c:set var="b" value="${sessionScope.b}" />
<c:set var="c" value="${requestScope.c}" />
<c:set var="d" value="${[Link]}" />
ContextVal:<c:out value="${a}"/><br>
SessionVal:<c:out value="${b}"/><br>
RequestVal:<c:out value="${c}"/><br>
PageVal:<c:out value="${d}"/><br> </body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
@WebServlet("/dis")
@ Override
HttpServletResponse res)
throws ServletException,IOException{
HttpSession hs = [Link]();
[Link]("a",100);
[Link]("b",200);
[Link]("c", 300);
RequestDispatcher rd = [Link]("[Link]");
[Link](req,res);
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
======================================================
(2)Function Tags:
syntax:
prefix="fn" %>
specified suffix.
of a specified substring.
fn:trim(): It removes the blank spaces from both the ends of a string.
case.
uppercase.
---------------------------------------------------------------
Ex:
[Link]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="post" action="[Link]">
Enter the String:<input type="text" name="str"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="[Link]
prefix="c" %>
<%@ taglib uri="[Link]
prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head> <body>
<c:set var="s1" value="${[Link]}"/>
<c:choose>
<c:when test="${fn:contains(s1, 'java')}">
<p>String Founded<p>
</c:when>
<c:otherwise>
<p>String Not Founded<p>
</c:otherwise>
</c:choose>
<c:if test="${fn:containsIgnoreCase(s1, 'JAVA')}">
<p>String Founded<p>
</c:if>
</body>
</html>
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
============================================================
(3)Formatting Tags:
syntax:
prefix="fmt" %>
and date.
*imp
-------------------------------------------------------------
Ex:
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c"
uri="[Link]
<%@ taglib prefix="fmt"
uri="[Link]
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1">
<title>Insert title here</title> </head>
<body> <h2>Different Formats of the Date</h2>
<c:set var="Date" value="<%=new [Link]()%>" />
[Link]
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
===========================================================
(4)XML Tags:
=>The JSTL XML tags are used for providing a JSP-centric way of
syntax:
(5)SQL Tags:
=>The SQL tag library allows the tags to Interact with RDBMS
or Oracle.
syntax:
<%@ taglib uri="[Link] prefix="sql" %>
Note:
================================================================
Dt : 11/7/2023
define pageContext?
objects of JSP.
getServletContext();
Note:
============================================================
define "page"?
[Link] class.
Note:
=========================================================
faq:
tag construction.
Hierarchy of JSP-Tag-API:
=>we use the following steps to construct Custom Tag:
step-1 : Create the Tag handler class and perform action at the
step-2 : Create the Tag Library Descriptor (TLD) file and define
tags
Step-3 : Create the JSP file that uses the Custom tag defined
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
@SuppressWarnings("serial")
try {
[Link]([Link]().getTime());
}catch(Exception e) {}
return SKIP_BODY;
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<tag>
<name>today</name>
<tag-class>[Link]</tag-class>
</tag>
</taglib>
[Link]
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
</head>
<body>
</body>
</html>
[Link]
<web-app>
<welcome-file-list>
<welcome-file>[Link]</welcome-file>
</welcome-file-list>
</web-app>
============================================================
Note:
============================================================
[Link]
@charset "ISO-8859-1";
h1 {
margin-left: 70px;
}
form li {
list-style: none;
margin-bottom: 5px;
}
form ul li label{
float: left;
clear: left;
width: 100px;
text-align: right;
margin-right: 10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
}
form textarea {
float: left;
width: 350px;
height: 150px;
}
[type="submit"] {
clear: left;
margin: 20px 0 0 230px;
font-size:18px
}
p {
margin-left: 70px;
font-weight: bold;
}
[Link]
/**
*
*/
function formValidation()
{
var uid = [Link];
var passid = [Link];
var uname = [Link];
var uadd = [Link];
var ucountry = [Link];
var uzip = [Link];
var uemail = [Link];
var umsex = [Link];
var ufsex = [Link];
if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(countryselect(ucountry))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
if(validsex(umsex,ufsex))
{
}
}
}
}
}
}
}
}
return false;
} function userid_validation(uid,mx,my)
{
var uid_len = [Link];
if (uid_len == 0 || uid_len >= my || uid_len < mx)
{
alert("User Id should not be empty / length be between "+mx+" to
"+my);
[Link]();
return false;
}
return true;
}
function passid_validation(passid,mx,my)
{
var passid_len = [Link];
if (passid_len == 0 ||passid_len >= my || passid_len < mx)
{
alert("Password should not be empty / length be between "+mx+"
to "+my);
[Link]();
return false;
}
return true;
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if([Link](letters))
{
return true;
}
else
{
alert('Username must have alphabet characters only');
[Link]();
return false;
}
}
function alphanumeric(uadd)
{
var letters = /^[0-9a-zA-Z]+$/;
if([Link](letters))
{
return true;
}
else
{
alert('User address must have alphanumeric characters only');
[Link]();
return false;
}
}
function countryselect(ucountry)
{
if([Link] == "Default")
{
alert('Select your country from the list');
[Link]();
return false;
}
else
{
return true;
}
}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if([Link](numbers))
{
return true;
}
else
{
alert('ZIP code must have numeric characters only');
[Link]();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-
]?\w+)*(\.\w{2,3})+$/;
if([Link](mailformat))
{
return true;
}
else
{
alert("You have entered an invalid email address!");
[Link]();
return false;
}
} function validsex(umsex,ufsex)
{
x=0;
if([Link])
{
x++;
} if([Link])
{
x++;
}
if(x==0)
{
alert('Select Male/Female');
[Link]();
return false;
}
else
{
alert('Form Succesfully Submitted');
[Link]()
return true;
}
}
[Link]
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>JavaScript Form Validation using a sample registration
form</title>
<meta name="keywords" content="example, JavaScript Form
Validation, Sample registration form" />
<meta name="description" content="This document is an example of
JavaScript Form Validation using a sample registration form. "
/>
<link rel='stylesheet' href='[Link]'
type='text/css' />
<script src="[Link]"></script>
</head>
<body onload="[Link]();">
<h1>Registration Form</h1>
Use tab keys to move from one input field to the next.
<form action="reg" method="post" name='registration'
onSubmit="return formValidation();">
<ul>
<li><label for="userid">User id:</label></li>
<li><input type="text" name="userid" size="12" /></li>
<li><label for="passid">Password:</label></li>
<li><input type="password" name="passid" size="12" /></li>
<li><label for="username">Name:</label></li>
<li><input type="text" name="username" size="50" /></li>
<li><label for="address">Address:</label></li>
<li><input type="text" name="address" size="50" /></li>
<li><label for="country">Country:</label></li>
<li><select name="country">
<option selected="" value="Default">(Please select a
country)</option>
<option value="Aus">Australia</option>
<option value="Canada">Canada</option>
<option value="India">India</option>
<option value="Russia">Russia</option>
<option value="USA">USA</option>
</select></li>
<li><label for="zip">ZIP Code:</label></li>
<li><input type="text" name="zip" /></li>
<li><label for="email">Email:</label></li>
<li><input type="text" name="email" size="50" /></li>
<li><label id="gender">Sex:</label></li>
<li><input type="radio" name="gen" value="Male"
checked="checked"/><span>Male</span></li>
<li><input type="radio" name="gen" value="Female"
/><span>Female</span></li>
<li><label>Language:</label></li>
<li><input type="checkbox" name="lan" value="english" checked
/><span>English</span></li>
<li><input type="checkbox" name="lan" value="hindi"
/><span>Hindi</span></li>
<li><input type="checkbox" name="lan"
value="telugu" /><span>Telugu</span></li>
<li><input type="checkbox" name="lan" value="noen" /><span>Non
English</span></li>
<li><label for="desc">About:</label></li>
<li><textarea name="desc" id="desc"></textarea></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ul>
</form>
</body>
</html>
[Link]
package test;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
@WebServlet("/reg")
IOException{
/* PrintWriter pw = [Link]();
[Link]("text/html");
[Link](userId+"<br>");
[Link](passId+"<br>");
[Link](userName+"<br>");
[Link](addr+"<br>");
[Link](country+"<br>");
[Link](zip+"<br>");
[Link](mId+"<br>");
[Link](gen+"<br>");
for(String l : lang)
[Link](l+"<br>");
}
[Link](desc+"<br>");*/
[Link]("[Link]").forward(req, res);
[Link]
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<style>
table, th, td {
border: 1px solid;
}
</style>
</head>
<body>
<table>
<tr>
<td>UserID</td>
<td><%=[Link]("userid") %></td>
</tr>
<tr>
<td>PassId</td>
<td><%=[Link]("passid") %></td>
</tr>
<tr>
<td>UserName</td>
<td><%=[Link]("username") %></td>
</tr>
<tr>
<td>Address</td>
<td><%=[Link]("address") %></td>
</tr>
<tr>
<td>Country</td>
<td><%=[Link]("country") %></td>
</tr>
<tr>
<td>ZIP</td>
<td><%=[Link]("zip") %></td>
</tr>
<tr>
<td>MailId</td>
<td><%=[Link]("email") %></td>
</tr>
<tr>
<td>Gender</td>
<td><%=[Link]("gen") %></td>
</tr>
<tr>
<td>Languages</td>
<td><%
String lang[] = [Link]("lan");
for(String str : lang)
{
%>
<%=str %>
<%
}
%>
</td>
</tr>
<tr>
<td>Description</td>
<td><%=[Link]("desc") %></td>
</tr>
</table>
</body>
</html>
======================================================
Dt : 13/7/2023
JDBC Objects : 10
Servlet Objects : 10
JSP Objects :9
EL-JSTL : 11
================
================
==================================================================
NASSCOM Examination:
Section-5 => UI :4
====================================
Total : 34
=====================================
Case Study :
DB Tables : AdminTab52
Student53(rno,name,br,totmarks,per,result)
StuMarks53(rno,tel,hin,eng,maths,sci,sco)