L. D.
College of
Engineering
Opp Gujarat University, Navrangpura, Ahmedabad -
LAB MANUAL
Branch: Computer Engineering
Advance Java Programming (3160707)
Semester: VI
Faculty Details:
1) Prof. P. G. Patel
2) Prof. K. M. Patel
3) Prof. P. J. Prajapati
4) Prof. S. A. Patel
5) Prof. R. A. Jaiswal
Advance Java Programming (3160707)
Certificate
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
1
Advance Java Programming (3160707)
L. D. College of Engineering
Computer Engineering Department
B.E. Semester:VI Term: Even-2022-23
INDEX
Enrollment No: 200280107082
Sr. Title CO Pa Date Marks Sign
No. ge RB1 RB2 RB3 RB4 Total
No. (5) (5) (5) (5) (20)
1 To implement reliable client- CO1
server communication using
TCP Socket API
2 To implement client-server CO1
communication using UDP
Socket API
3 To develop JDBC CO1
application
4 To create a web application CO2
using servlet API
5 To demonstrate session CO2
management using servlet
API.
6 To create a web application CO2
using servlet event handling
and filters.
7 To create a web application CO3
using JSP
8 To develop a web CO3
application using JSP and
JDBC
9 To develop a web CO3
application using JSTL
10 To demonstrate the use of CO4
hibernate framework
11 To demonstrate the use JSF CO4
framework
12 To demonstrate the use CO4
spring framework
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
2
Advance Java Programming (3160707)
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
3
Advance Java Programming (3160707)
L. D. College of Engineering
Computer Engineering Department
B.E (Computer Engineering)
Semester: VI (Division: C) Term: Even-2022-23
Course Name: Advance Java Programming (3160707)
Rubrics for Practical Assessment
Rubrics Criteria Marks Good (2) Satisfactory Need
ID (1) Improvement
(0)
RB1 Regularity 05 High (>70%) Moderate (40- Poor (0-40%)
70%)
RB2 Problem 05 Apt & Full Limited Very Less
Analysis & Identification of Identification Identification of
Development of the Problem & of the the Problem /
the Solution Complete Problem / Very Less
Solution for the Incomplete Solution for the
Problem Solution for Problem
the Problem
RB3 Testing of the 05 Correct Solution Partially Very less correct
Solution as required Correct solution for the
Solution for problem
the Problem
RB4 Mock viva test 05 All questions Delayed & Very few
responded partially questions
Correctly correct answered
response correctly
SIGN OF FACULTY
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
4
Advance Java Programming (3160707)
GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD,
COURSE CURRICULUM
COURSE TITLE: Advance Java Programming
(Code: 3160707)
Degree Programmes in which this course is offered Semester in which offered
Computer Engineering 6th Semester
1. RATIONALE
• To study APIs for the given networking and database application.
• To implement servlet, JSP for the different server side problem.
• To develop web application using MVC based framework.
2. COMPETENCY
The course content should be taught and analyze with the aim to develop different types of skills
so that students are able to acquire following competency:
Develop webapplicaiton using MVC framework.
3. COURSE OUTCOMES
After learning the course the students should be able to:
1. Use java APIs for the development of networking and database application.
2. Implement Server side problems using the servlet API.
3. Develop Dynamic web application using JSP.
4. Demonstrate the use of Hibernate, JSF and Spring web frameworks.
5. Design web application using MVC Framework.
4. TEACHING AND EXAMINATION SCHEME
Teaching Scheme Credits Examination Marks
Theory Marks Practical Marks Total
L T P C Marks
ESE(E) PA (M) ESE(E) PA (I)
3 0 2 4 70 30 30 20 150
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
5
Advance Java Programming (3160707)
5. SUGGESTED LEARNING RESOURCES
A. LIST OF BOOKS
1) Black Book “ Java server programming” J2EE, 1st ed., Dream Tech Publishers, 2008. 3.
Kathy walrath ”
2) Complete Reference J2EE by James Keogh mcgraw publication
3) Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
4) SCWCD, Matthew Scarpino, Hanumant Deshmukh, Jignesh Malavie, Manning publication
5) Core Java, Volume II: Advanced Features by Cay Horstmann and Gary Cornell Pearson
Publication
6) Java Persistence with Hibernate by Christian Bauer, Gavin King
7) Spring in Action 3rd edition , Craig walls, Manning Publication
8) Hibernate 2nd edition, Jeff Linwood and Dave Minter, Beginning Après publication
9) Java Server Faces in Action, Kito D. Mann, Manning Publication
10) JDBC™ API Tutorial and Reference, Third Edition, Maydene Fisher, Jon Ellis, Jonathan
Bruce, Addison Wesley
11) Beginning JSP, JSF andTomcat, Giulio Zambon, Apress
12) JSF2.0 CookBook, Anghel Leonard, PACKT publication
13) Advanced Java, M. T. Savaliya, dreamtech
B. LIST OF SOFTWARE / LEARNING WEBSITES
https://netbeans.apache.org/
https://www.eclipse.org/downloads/
https://dev.mysql.com/downloads/installer/
https://www.java.com/en/
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
6
Advance Java Programming (3160707)
Practical – 1
AIM: To implement reliable client-server communication using TCP Socket API.
Write a java program where client sends a string as a message and sever counts the characters in
the received message from client. Server sends this value back to the client. Server should be
able to serve multiple clients simultaneously.
Objectives: To learn client server communication using TCP socket API in java.
Theory:
Sockets provide the communication mechanism between two computers using TCP.
A client program creates a socket on its end of the communication and attempts to
connect that socket to a server.
When the connection is made, the server creates a socket object on its end
of the communication. The client and the server can now communicate by
writing to and reading from the socket.
The java.net.Socket class represents a socket, and the
java.net.ServerSocket class provides a mechanism for the server
program to listen for clients and establish connections with them.
The client in socket programming must know two information:
1. IP Address of Server
2. Port number
Tools / Material Needed:
Hardware: Laptop
Software: IntelliJ Community, OpenJDK 19
Procedure:
o Creating Server: To create the server application, we need to create the
instance of ServerSocket class. Here, we are using 3333 port number for the
communication between the client and server. You may also choose any
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
7
Advance Java Programming (3160707)
other port number. The accept() method waits for the client. If clients
connects with the given port number, it returns an instance of Socket.
1. ServerSocket s = new ServerSocket(3000);
2. Socket socket = s.accept();
o Creating Client: To create the client application, we need to create the
instance of Socket class. Here, we need to pass the IP address or hostname
of the Server and a port number. Here, we are using "localhost" because our
server is running on same system.
1. Socket socket=new Socket("localhost",3000)
Code:
Server-Side Program:
import java.io.*;
import java.net.*;
public class P1_TCPServer{
public static void main(String[] args) throws IOException {
try (ServerSocket serverSocket = new ServerSocket(3000)) {
System.out.println("Server is listening on port 3000");
while (true) {
Socket clientSocket = serverSocket.accept();
System.out.println("New client connected");
Thread t = new Thread(new ClientHandler(clientSocket));
t.start();
}
}
}
}
class ClientHandler implements Runnable {
private Socket clientSocket;
public ClientHandler(Socket socket) {
this.clientSocket = socket;
}
public void run() {
try {
BufferedReader in = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
8
Advance Java Programming (3160707)
PrintWriter out = new
PrintWriter(clientSocket.getOutputStream(), true);
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println("Received message from client: " +
inputLine);
int count = inputLine.length();
out.println(count);
}
in.close();
out.close();
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Client-side Program:
import java.io.*;
import java.net.*;
public class P1_TCPClient1{
public static void main(String[] args) throws IOException {
String hostName = "localhost";
int portNumber = 3000;
try (
Socket clientSocket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),
true);
BufferedReader in = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
BufferedReader stdIn = new BufferedReader(new
InputStreamReader(System.in)))
{
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
String response = in.readLine();
System.out.println("Server response: " + response);
}
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
9
Advance Java Programming (3160707)
} catch (UnknownHostException e) {
System.err.println("Unknown host: " + hostName);
System.exit(1);
} catch (IOException e) {
System.err.println("I/O error occurred");
System.exit(1);
}
}
}
Output:
Client-1 Output:
Client-2 Output:
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
10
Advance Java Programming (3160707)
Server Side Output:
Signature of Faculty: Grade:
Computer Engineering Department, L. D. College of Engineering, Ahmedabad-15
11