Professional Documents
Culture Documents
Av. Java QB
1. Explain OSI model in brief with diagram.
physical layer:
lowest layer
information ⇒ bits
When receiving data, this layer will convert it into bits and send them to the
Data Link layer, which will put the frame back together.
Bit synchronization
Physical topologies
Transmission mode
Av. Java QB 1
When a packet arrives in a network, DLL transmits it to the Host using its
MAC address.
Sublayers:
Functions:
Framing
Physical addressing
Error control
Flow Control
Access control
Network Layer:
transmission of data
Functions:
Routing
Logical Addressing
Transport Layer:
At sender’s side
At receiver’s side:
functions:
Av. Java QB 2
Segmentation and Reassembly
Session Layer
Functions:
Synchronization
Dialog Controller
Presentation Layer
Translation layer
Functions:
Translation
Encryption/ Decryption
Compression
Application Layer
window for the application services to access the network and for displaying
information to the user.
Functions:
Mail Services
Directory Services
2. Write a short note on socket programming with server socket and client
socket.
Av. Java QB 3
connection-oriented ⇒ Socket and ServerSocket classes
or connection-less ⇒ DatagramSocket and DatagramPacket classes
Socket class
Method Description
ServerSocket class
Method Description
Example
Creating Server:
Av. Java QB 4
create the instance of ServerSocket class
Creating Client
MyServer.java
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("message= "+str);
ss.close();
}catch(Exception e){System.out.println(e);}
}
}
MyClient.java
import java.io.*;
import java.net.*;
public class MyClient {
public static void main(String[] args) {
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}catch(Exception e){System.out.println(e);}
}
}
Av. Java QB 5
3. Write a short note on:
RPC
The client stub passes the message to the transport layer, which sends
it to the remote server machine.
Av. Java QB 6
The transport layer sends the result message back to the client
transport layer
A stub for a remote object acts as a client’s local representative or proxy for the
remote object. The caller invokes a method on the local stub which is
responsible for carrying out the method call on the remote object.
The stub hides the serialization of parameters and the network-level
communication in order to present a simple invocation mechanism to the caller.
The skeleton is responsible for dispatching the call to the actual remote object
implementation.
When a skeleton receives an incoming method invocation it does the following:
3.writes and transmits the result (return value or exception) to the caller.
Multicast Socket
Av. Java QB 7
create an interface ⇒ provide a description of the methods
Step 2: Implementation of remote interface
The RMIC tool is used to invoke the RMI compiler that creates the Stub
and Skeleton objects. Its prototype is RMIC class name.
You need to start the registry service by issuing the command at the
command prompt start RMIregistry
Repeater
regenerates the signal over the same network before the signal becomes
too weak
Av. Java QB 8
do not amplify the signal
When the signal becomes weak, they copy it bit by bit and regenerate it at
its star topology connectors
Hub
multi-port repeater
Types of Hub
Active Hub
These are the hubs that have their power supply and can clean,
boost, and relay the signal along with the network.
Passive Hub
These are the hubs that collect wiring from nodes and power supply
from the active hub.
relay signals onto the network without cleaning and boosting them
Intelligent Hub
Bridge
Types of Bridges
Transparent Bridges
Switch
Av. Java QB 9
a multiport bridge with a buffer and a design that can boost its efficiency
and performance
Routers
connect LANs and WANs and have a dynamically updating routing table
Gateway
passage to connect two networks that may work upon different networking
models.
Brouter
NIC
Av. Java QB 10
6. Brief note on computer network with network types.
Examples of CAN are networks that cover schools, colleges, buildings, etc.
Examples are networking in towns, cities, a single large city, large area
within multiple buildings, etc.
Av. Java QB 11
Examples are a network of disks accessed by a network of servers.
alternative to a LAN
uses optical splitters to split of single mode optical fibre to multiple signals
to distribute users and devices.
extends a private network across the internet and lets the user send and
receive data as if they were connected to a private network even though
they are not.
network types
Av. Java QB 12
Examples of LAN are networking in a home, school, library, laboratory,
college, office, etc.
Examples are networking in towns, cities, a single large city, large area
within multiple buildings, etc.
alternative to a LAN
Av. Java QB 13
uses optical splitters to split of single mode optical fibre to multiple
signals to distribute users and devices.
extends a private network across the internet and lets the user send
and receive data as if they were connected to a private network even
though they are not.
topologies
Mesh Topology:
Advantages
fast communication
Av. Java QB 14
fault is diagnosed easily
Problems
Star Topology:
Advantages
robust
cost-effective
Problems
Bus Topology:
Av. Java QB 15
every computer and network device is connected to a single cable
bi-directional
Advantages
familiar technology
Problems
lot of cabling
Ring Topology:
Av. Java QB 16
data flows in one direction
Token passing
Token
Advantages
collision is minimum
less costly
Problems
Tree Topology:
Advantages
Av. Java QB 17
It allows the network to get isolated and also prioritize from different
computers.
Problems
difficult to reconfigure.
network devices
Repeater
regenerates the signal over the same network before the signal
becomes too weak
When the signal becomes weak, they copy it bit by bit and regenerate it
at its star topology connectors
Hub
multi-port repeater
Types of Hub
Active Hub
These are the hubs that have their power supply and can clean,
boost, and relay the signal along with the network.
Passive Hub
These are the hubs that collect wiring from nodes and power
supply from the active hub.
Av. Java QB 18
relay signals onto the network without cleaning and boosting
them
Intelligent Hub
Bridge
Types of Bridges
Transparent Bridges
Switch
a multiport bridge with a buffer and a design that can boost its efficiency
and performance
Routers
Av. Java QB 19
routes data packets based on their IP addresses.
Gateway
Brouter
NIC
2 tier architecture
direct communication
1. Client tier
2. Data tier
Av. Java QB 20
the code is written for saving the data in the SQL server database.
Client sends the request to the server and it processes the request
& sends it back with data.
2. Communication is faster
Disadvantages:
2. Cost-ineffective
When you design the solution for web- application you have to keep
in mind the below points:
1. Availability
2. Security
3. Performance
4. Reliability
5. Cost Optimization
3 tier architecture
Av. Java QB 21
it is a modular client-server architecture
Presentation tier
Application tier
Data tier
Benefits
1. horizontal scalability
2. performance
Av. Java QB 22
3. availability
4. concurrent development
6. easy to evolve
https://www.geeksforgeeks.org/life-cycle-of-a-servlet/
https://www.tutorialspoint.com/servlets/servlets-first-example.htm#
Servlet vs CGI
Since codes are written in Since codes are written in any language,
Java, it is object oriented all the languages are not object-oriented
Object-Oriented
and the user will get the thread-based. So, the user will not get
benefits of OOPs the benefits of OOPs
Server It can use any of the web- It can use the web-server that supports
Independent server. it.
It links directly to the It does not link the web server directly to
Link
server. the server.
It can read and set HTTP It can neither read nor set HTTP
HTTP server
servers. servers.
Construction and
Construction and destruction of the new
Cost destruction of new
processes are costly.
threads are not costly.
Av. Java QB 23
Speed It’s speed is slower. It’s speed is faster.
💡 Servlets are the Java programs that run on the Java-enabled web
server or application server.
Add columns
Step 3: Create required JSP’s to get the details from the student
Home.jsp
<tr>
<td>To insert your details into the Database:</td>
<td><input type="button" value="Insert data"
onclick="window.location.href='Insert.jsp'" /></td>
</tr>
<tr>
<td>To delete your details from the Database:</td>
<td><input type="button" value="Delete data"
onclick="window.location.href='Delete.jsp'" /></td>
</tr>
Insert.jsp
Av. Java QB 24
Step 4: Create DBUtil.java
fetch the values from the DB, click on Select Data on the Home page.
HTTP tunneling
Av. Java QB 25
HTTP tunneling is the process in which communications are encapsulated
by using HTTP protocol.
used for network locations which have restricted connectivity or are behind
firewalls or proxy servers.
sits between a group of client users and the wider outside Internet
In HTTP tunneling, HTTP protocol acts as a wrapper for a channel that the
network protocol being tunneled uses to communicate.
HTTP tunnel software is used for this purpose and allows communication
with restricted network connectivity.
Servlet chaining
Forward model:
Av. Java QB 26
Include model:
Deployment description
Av. Java QB 27
<servlet> ⇒ declares the servlet class and a logical name used to refer to
the servlet by other elements in the file.
The standard does not support wildcards in the middle of a string, and does
not allow multiple wildcards in one pattern.
https://www.geeksforgeeks.org/servlet-form/
session management
User Authorization:
login credentials of the user are passed via server and client to
maintain the servlet session.
URL rewriting:
Hidden Fields:
Av. Java QB 28
Cookies:
1. open the file menu, select new and then click jasper report
3. select the folder in the workspace where you want to put the report and
name the new report
4. click next
6. left hand list shows all the discovered fields, the right hand list shows those
that will be added to the report
8. click next
9. click finish
Av. Java QB 29
calling jasper report
Navigate to your report's JRXML, and click Run Report Unit. If prompted to
save the report unit, specify a location on your local computer and click OK.
If the report has input controls that require values, you'll be prompted to
specify them. The report appears in a browser window.
ServletContext
Advantage of ServletContext
easy to maintain
can be used to set, get or remove attribute from the web.xml file.
getServletContext() method
getServletContext() method
Av. Java QB 30
config object
This object allows the JSP programmer access to the Servlet or JSP engine
initialization parameters such as the paths or file locations etc.
The following config method is the only one you might ever use, and its
usage is trivial
config.getServletName();
This returns the servlet name, which is the string contained in the <servlet-
name> element defined in the WEB-INF\web.xml file.
https://www.cosmiclearn.com/servlet/eventhandling.php
Servlet JSP
Servlet can accept all protocol requests. JSP only accepts HTTP requests.
In Servlet, we can override the service() In JSP, we cannot override its service()
method. method.
In Servlet by default session management is In JSP session management is
not enabled, user have to enable it explicitly. automatically enabled.
In Servlet we have to implement everything like In JSP business logic is separated from
business logic and presentation logic in just presentation logic by using
one servlet file. JavaBeansclient-side.
Av. Java QB 31
Modification in Servlet is a time-consuming JSP modification is fast, just need to click
compiling task because it includes reloading, the refresh button.
recompiling, JavaBeans and restarting the
server.
It does not have inbuilt implicit objects. In JSP there are inbuilt implicit objects.
https://www.javatpoint.com/mvc-architecture-in-java
https://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm#:~:text=The
JavaServer Pages Standard Tag,internationalization tags%2C and SQL tags.
basic tags
Av. Java QB 32
the JSP engine.
basic objects
instance of a javax.servlet.http.HttpServletReqt
object.
Each time a client requests a page the JSP engine creates a new
object to represent that request.
instance of a javax.servlet.http.HttpServletRese
object.
defines the interfaces that deal with creating new HTTP headers.
programmer can add new cookies or date stamps, HTTP status codes,
etc.
an instance of a javax.servlet.jsp.JspWriter
object and is used to send content in a response.
an instance of javax.servlet.http.HttpSession
and behaves exactly the same way that session objects behave under
Java Servlets.
Av. Java QB 33
The config Object
This object allows the JSP programmer access to the Servlet or JSP
engine initialization parameters such as the paths or file locations etc.
action tags
jsp:param sets the parameter value. It is used in forward and include mostly.
Av. Java QB 34
java server tag library
https://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm#:~:text=The
JavaServer Pages Standard Tag,internationalization tags%2C and SQL tags.
https://www.javaguides.net/2019/08/java-mvc-web-application-using-jsp-and-
servlet.html
Av. Java QB 35
Configuration:
Session:
Transaction:
used when we perform any operation and based upon that operation there
is some change in database.
give the instruction to the database to make the changes that happen
because of operation as a permanent by using commit() method.
Query:
extra functionality
Criteria:
Av. Java QB 36
simplified API for retrieving entities by composing Criterion objects.
Flow of working
https://www.javatpoint.com/steps-to-create-first-hibernate-application
Av. Java QB 37
ORM is the solution for handling:
Granularity Sometimes you will have an object model, which has more classes than
the number of corresponding tables in the database.
Inheritance RDBMSs do not define anything similar to Inheritance, which is a natural
paradigm in object-oriented programming languages.
Identity An RDBMS defines exactly one notion of 'sameness': the primary key. Java,
however, defines both object identity (a==b) and object equality (a.equals(b)).
Navigation The ways you access objects in Java and in RDBMS are fundamentally
different.
Entities of ORM:
Sr.No. Solutions
Advantages of ORM
Sr.No. Advantages
Av. Java QB 38
💡 Hibernate Query Language (HQL) is an object-oriented query language,
similar to SQL, but instead of operating on tables and columns, HQL
works with persistent objects and their properties. HQL queries are
translated by Hibernate into conventional SQL queries, which in turns
perform action on database.
Clauses in HQL
FROM Clause
AS clause
SELECT clause
WHERE
ORDER BY
GROUP BY
UPDATE
DELETE
INSERT
HQL is an XML file format to link java from the front end to the database in
the back end.
Advantages of HQL
Av. Java QB 39
💡 check this out on youtube
https://www.codejava.net/frameworks/struts/struts-2-spring-4-hibernate-4-
integration-tutorial-part-1-xml-configuration#:~:text=Struts is a web
application,and it can replace Struts.
https://struts.apache.org/getting-started/spring
https://www.tutorialandexample.com/struts-2-database-connection-example
26. Brief note on: Spring core module and sprint J2EE module
core component
implementations of container:
bean factory
Av. Java QB 40
central IoC container that is responsible for instantiating application
objects
application context
light weight
Benefits
modularity
code tends to be very easy to make test cases for various testings
Disadvantages
complex to build
unclear guidelines
https://www.geeksforgeeks.org/introduction-to-spring-framework/
Av. Java QB 41
spring J2EE module
spring ORM
spring JDBC
https://www.geeksforgeeks.org/spring-jdbc-template/
spring AOP
Ant Maven
The ant scripts are not reusable. The maven plugins are reusable.
https://www.javatpoint.com/maven-repository
https://www.simplilearn.com/tutorials/maven-tutorial/what-is-maven
https://www.w3schools.blog/maven-pom-xml-file
Av. Java QB 42
32. What are WS components in detail.
https://www.javatpoint.com/web-service-components
https://www.edureka.co/blog/java-web-services-tutorial/
https://www.simplilearn.com/tutorials/java-tutorial/what-is-junit
Features of JAXB
2) Support for all W3C XML Schema features: it supports all the W3C
schema unlike JAXB 1.0.
4) Small Runtime Library: it required small runtime library that JAXB 1.0.
5) Reduction of generated schema-derived classes: it reduces a lot of
generated schema-derived classes.
Av. Java QB 43
💡 Definition of JAXB
The Java™ Architecture for XML Binding (JAXB) provides an API and
tools that automate the mapping between XML documents and Java
objects.
The JAXB framework enables developers to perform the following
operations:
Marshal the Java representation of the XML content into XML content
JAXB
https://www.geeksforgeeks.org/java-architecture-for-xml-binding-jaxb-set-1/
object to XML
Steps:
6. https://www.javatpoint.com/jaxb-tutorial
XML to object
steps
https://www.javatpoint.com/jaxb-tutorial
Av. Java QB 44
Maven repositories
https://www.javatpoint.com/maven-repository
WS component
https://www.w3schools.blog/maven-pom-xml-file
JUNIT testing
https://www.simplilearn.com/tutorials/java-tutorial/what-is-junit
Av. Java QB 45