[go: up one dir, main page]

0% found this document useful (0 votes)
14 views28 pages

Varun

Uploaded by

varunkvarun95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views28 pages

Varun

Uploaded by

varunkvarun95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Java full Stack Internship

Chapter-1
Introduction
1. Introduction to java
With the invention of microprocessors, the world is scientifically developed with sophisticated
equipment, system, and devices. Microprocessors are used in computers, television, and fax
machines. Even the handheld devices such as pages, PDAs(Personal Digital Assistant), and cell
phones make use of microprocessors. All these electronic devices are helpful because of their
communication capabilities. With the increasing capabilities and decreasing cost of information
processing and networking technologies, the network is growing rapidly for
transmitting information through electronic systems.
Internet is the network of networks between different types of computers located at different
places to transmit information. Information can reach to any place in the world quickly at a
cheaper rate through the Internet. Thus, the Internet has made the world a global village for
information exchange. The emerging infrastructure of electronic devices and interconnected
computer networks create an environment that presents new challenges to software industries. for
this emerging computing environment, Java process to be a well - suited programming language.
it is found suitable for networked environments involving a great variety of computer
and devices.

There were five primary goals in the creation of the Java language.
• It should be "simple, object-oriented and familiar"
• It should be "robust and secure".
• It should be "architecture-neutral and portable".
• It should execute with "high performance".
• It should be "interpreted, threaded, and dynamic”.

Java does have some drawbacks. Since it has automated garbage collection, it can tend to use
more memory than other similar languages. There are often implementation differences on
different platforms, which have led to Java being described as a "write once, test everywhere"
system. Lastly, since it uses an abstract "virtual machine", a generic Java program doesn't have
access to the Native API's on a system directly. None of these issues are fatal, but it can mean
that Java isn't an appropriate choice for a particular piece of software

DEPT.of CSE,MRIT Mandya. 2023-24 Page 1


Java full Stack Internship

Chapter-2
The Java Platform
One thing that distinguished Java from some other languages is its ability to run the same
compiled code across multiple operating systems. In other languages, the source code (code that
is written by the programmer), is compiled by a compiler into an executable file. This file is in
machine language, and is intended for a single operating system/processor combination, so the
programmer would have to recompile the program separately for each new operating system/
processor combination. Java is different in that it does not compile the code directly into machine
language code. Compilation creates byte code out of the source code. Byte code generally looks
something like this:
a7 f4 73 5a 1b 92 7d
When the code is run by the user, it is processed by something called the Java Virtual Machine
(JVM). The JVM is essentially an interpreter for the byte code. It goes through the byte code and
runs it. There are different versions of the JVM that are compatible with each OS and can run the
same code. There is virtually no difference for the end-user, but this makes it a lot easier for
programmers doing software development.

Java and Open Source:-


• In 2006 Sun started to make Java available under the GNU General Public License(GPL).
Oracle continues this project called OpenJDK.

Java Virtual Machine:-


• The Java virtual machine (JVM) is a software implementation of a computer that executes
programs like a real machine.
• The Java virtual machine is written specifically for a specific operating system, e.g. for Linux a
special implementation is required as well as for Windows.
• Java programs are compiled by the Java compiler into bytecode. The Java virtual machine
interprets this bytecode and executes the Java program.

Java Runtime Environment vs. Java Development Kit:-


• A Java distribution comes typically in two flavours, the Java Runtime Environment (JRE) and
the Java Development Kit (JDK).
• The Java runtime environment (JRE) consists of the JVM and the Java class libraries and
contains the necessary functionality to start Java programs.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 2


Java full Stack Internship
• The JDK contains in addition the development tools necessary to create Java programs.The
JDK consists therefore of a Java compiler, the Java virtual machine, and the Java class libraries

DEPT.of CSE,MRIT Mandya. 2023-24 Page 3


Java full Stack Internship

Chapter-3
Check installation and Configuring Variables
• Java might already be installed on your machine. You can test this by opening a console (if you
are using Windows: Win+R, enter cmd and press Enter) and by typing in the following
command java -version.
• If Java is correctly installed, you should see some information about your Java installation. If
the command line returns the information that the program could not be found, you have to
install Java

Installing the Java Development Kit:-


Before installing the Java Development Kit (JDK), you should probably know what it is.It is
distributed by Oracle. It contains the core libraries and compiler required to develop Java.The
JDK should not be confused with the JRE (Java Runtime Environment). The JRE is a JVM for
running, as opposed to compiling, Java programs.

Downloading and Installing:-


To download the JDK, go to http://www.oracle.com/technetwork/java/javase/downloads/
index.html.Click on “IDK with NetBeans Bundle". Follow the instructions for downloading the
JDK installation file.Windows: If you are running Windows, simply run the executable file and
follow the installation instructions.
Unix, Solaris, or Linux: For Linux and Unix, download the "jdk 6.0" for Linux systems. Save
the downloaded file in any drive. Once you have saved the file, extract it to a place that you can
remember, by using Terminal or by double clicking on the file.
When you have finished extracting the file, copy the JDK 1.6.0 folder and paste it in the usr/
local(To paste to the usr/local directory, you have to be in root) so that every user can use the java
files. You can delete the downloaded zip file so that it doesn't take up space on your drive.
Macintosh: The latest available JDK is automatically installed by the operating system. Because
Java for Macintosh is developed and maintained by Apple, in coordination with Sun, the current
version on the Macintosh may not be the current version that is available

Note on Editions:-
The JDK comes in three editions.
2. Java Standard Edition (JSE) - This version is the basic platform for Java. The course will
focus on this edition.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 4



Java full Stack Internship
3. Java Enterprise Edition (JEE) - This edition is mainly for developing and running distributed
multi-tier architecture Java applications, based largely on modular software components
running on an application server. We will not be covering this version in the course.
4. Java Micro Edition (JME) - This edition is primarily for developing programs to run on
consumer appliances, such as PDAs and cell phones.

Configuring Variables:-
• Before writing code, it is recommended that you set the Path variable on your system so you
can compile your code more easily.

For Windows Users:-


• From the Control Panel, double click "System" (System and Maintenance in Vista)
• For Windows Vista, 7, 8 and 10 click on "System," "Advanced System Settings" on the left,
and then on "Environment Variables."
• For XP and 2000, click on the "Advanced" tab and click on "Environment Variables" For NT,
click on the "Environment" tab.
• Select the Path variable and click "Edit"
• Add the path to the bin directory of where Java is installed on your hard drive. It should
probably be: C: Program Files\Java\jdk1.6.0_20bin unless you changed it during installation.
• Click OK

For Linux and UNIX:-


• One way to set your path in Linux/Unix is to add a path export to your bash profile.
• In order to do this, first open your bash profile in a text editor. For example, pico
~/.bash_profile
• Then add this line: export PATH=$PATH:/usr/local/jdk/bin
• Note that the path to the java directory "/usr/local/jdk/bin" may be different on your machine.
• Restart your shell

For Macintosh:-
• Apple sets everything up for you. Sit back and relax.
• The only drawback is that because Apple handles development and maintenance of Java on the
Mac, there is usually a delay from the time that a new version is released by Sun and the time
that the new version is released on the Mac. Also, getting the latest version sometimes requires
an operating system upgrade.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 5


Java full Stack Internship
Validate installation:-
• Switch again to the command line and run the following command.
• java -version
• The output should be similar to the following output. java version “1.7.0_25”
• OpenJDK Runtime Environment (IcedTea 2.3.10) (725-2.3.10-lubuntu0.13.04.2)
• OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Development Process with Java:-


• Java source files are written as plain text documents. The programmer typically writes Java
source code in an Integrated Development Environment (IDE) for programming. An IDE
supports the programmer in the task of writing code, e.g. it provides auto-formatting of the
source code, highlighting of the important keywords, etc.
• At some point the programmer (or the IDE) calls the Java compiler (javac). The Java compiler
creates the bytecode instructions. These instructions are stored in class files and can be
executed by the Java Virtual Machine.

Garbage collector:-
• The JVM automatically re-collects the memory which is not referred to by other objects. The
java garbage collector checks all object references and find the objects which can be
automatically released.
• While garage collector releases the programers from the need to explicitly manage memory the
programers still need to ensure that he does not keep unnecessary object references otherwise
the garbage collector cannot release the associated memory. Keeping unneeded object
references are typically called memory leaks.

Class path:-
• The class path defines where the Java compiler and Java runtime look for class files to load.
This instructions can be used in the Java program.
• For example if you want to use an external Java library you have to add this library to your
class path to use it in your program.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 6


Java full Stack Internship

Chapter-4
JAVA BASIC TERMS
Basics: Package, Class and Object
It is important to understand the base terminology of Java in terms of packages, classes and
objects. This section gives an overview of these terms.

Packages:
Java groups classes into functional packages.Packages are typically used to group classes into
logical units. For example all graphical views of an application might be placed in the same
package called com.vogella.webapplication.views.
It is common practice to use the reverse domain name of the company as top level package. For
example the company might own the domain, vogella.com and in this example the Java packages
of
this company starts with com.vogella.
Other main reason for the usage of packages is to avoid name collisions of classes. A name
collision occurs if two programmers give the same fully qualified name to a class. The fully
qualified name of a class in Java consists out of the package name followed by a dot (.) and the
class name.
Without packages, a programmer may create a Java class called Test. Another programmer may
create a class with the same name. With the usage of packages you can tell the system which
class to call. For example if the first programmer puts the Test class into package report and the
second programmer puts his class into package xmlreader you can distinguish between these
classes by using the fully qualified name, e.g. xmlreader. Test or report. Test.

Class:
Def.: Template that describes the data and behaviour associated with an instance of that class. In
Java source code a class is defined by the class keyword and must start with a capital letter. The
body of a class is surrounded by {}. The data associated with a class is stored in variables ; the
behaviour associated to a or object is implemented with class methods.
A class is contained in a Java source file with the same name as the class plus the java extension.

Object:
Def.: An object is an instance of a class.The object is the real element which has data and can
perform actions. Each object is created based on class definition.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 7


Java full Stack Internship

Chapter-5
VARIABLES AND METHODS
• Variable
Variables allow the Java program to store values during the runtime of the program.
A variable can either be a primitive variable or a reference variable. A primitive variable contains
value while the reference variable contains a reference (pointer) to the object. Hence if you
compare two reference variables, you compare if both point to the same object. To compare
objects use the objectl.equals(object2) method call.

• Instance variable
Instance variable is associated with an instance of the class (also called object). Access works
over these objects.
Instance variables can have any access control and can be marked final or transient. Instance
variables marked as final can not be changed after assigned to a value.

• Local variable
Local (stack) variable declarations cannot have access modifiers.
final is the only modifier available to local variables. This modifier defines that the variable
cannot be changed after first assignment.
Local variables do not get default values, so they must be initialised before use.

• Methods
A method is a block of code with parameters and a return value. It can be called on the object.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 8


Java full Stack Internship

Method can be declared with var-args. In this case the method declares a parameter which
accepts from zero to many arguments (syntax: type .. name;) A method can only have one var-
args parameter and this must be the last parameter in the method.
Overwrite of a superclass method: A method must be of the exact same return parameter and the
same arguments. Also the return parameter must be the same. Overload methods: An overloaded
method is a method with the same name, but different arguments. The return type can not be used
to overload a method.

• Constructor

A class contains constructors that are invoked to create objects based on the class definition.
Constructor declarations look like method declarations except that they use the name of the class
and have no return type. A class can have several constructors with different parameters. Each
class must define at least one constructor.
Following is a simple example the constructor.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 9


Java full Stack Internship

Chapter-6
INHERITANCE
A class can be derived from another class. In this case this class is called a subclass. Another
common phrase is that a class extends another class.
The class from which the subclass is derived is called a superclass.
Inheritance allows a class to inherit the behaviour and data definitions of another class. The
following codes demonstrates how a class can extend another class. In Java a class can extend a
maximum of one class.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 10


Java full Stack Internship

Chapter-7
METHOD AND CONSTRUCTOR OVERLOADING
• Method overloading:-
Method Overloading is a feature that allows a class to have more than one method having the
same name, if their argument lists are different. It is similar to constructor overloading in Java
that allows a class to have
more than one constructor having different argument lists.
To understand method overloading following programme can be use:

• Constructor overloading:-
Like methods, constructors can also be overloaded.
Constructor overloading is a concept of having more than one constructor with different
parameters list, in such a way so that each constructor performs a different task.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 11


Java full Stack Internship

Following programme explains constructor overloading:

DEPT.of CSE,MRIT Mandya. 2023-24 Page 12


Java full Stack Internship

Chapter-8
MODIFIERS
There are three access modifiers keywords available in Java. public, protected and private. There
are four access levels: public, protected, default and private. They define how the corresponding
element is visible to other components.If something is declared public, e.g. classes or methods
can be freely created or called by other Java objects. If something is declared private, e.g. a
method, it can only be accessed within the class in which it is declared. protected and default are
similar. A protected class can be accessed from the package and sub-classes outside the package
while a default class can get only accessed via the same package.
The following table describes the visibility:

Modifier Class Package Subclass World

Public Y Y Y Y

Protected Y Y Y N

No modifier Y Y N N

Private Y N N N

Other Modifier:
• final methods: cannot be overwritten in a subclass
• abstract method: no method body
• synchronised method: threat safe, can be final and have any access control
• native methods: platform dependent code, apply only to methods
• Strictfp: class or method.

Import statements
• Usage of import statements: In Java you have to access a class always via its full-qualified
name, e.g. the package name and the class name. You can add import statements for classes or

DEPT.of CSE,MRIT Mandya. 2023-24 Page 13


Java full Stack Internship
packages into your class file, which allow you to use the related classes in your code without the
package.
• Static imports:
Static import is a feature that allows members (fields and methods) which are defined in a class
with the public static access modifier to be used in Java code without specifying the class in
which the member is defined. The feature provides a type safe mechanism to include constants
into code without having to reference the class that originally defined

DEPT.of CSE,MRIT Mandya. 2023-24 Page 14


Java full Stack Internship

Chapter-9
INTERFACE
Interfaces are contracts for what a class can do but they say nothing about the way in which the
class must do it. An interface is a type similar to a class. Like a class an interface defines
methods. An interface can have only abstract methods, no concrete methods are allowed.
Methods defined in interfaces are by default public and abstract - explicit declaration of these
modifiers is optional. Interfaces can have constants which are always implicitly public, static and
final. A class can implement an interface. In this case it must provide concrete implementations
of the interface methods. If you override a method defined by an interface you can also use the
@override annotation.

• Abstract class and methods:


A class and method can be declared as abstract. An abstract class can not be directly instantiated.
If a class has at least one method which only contain the declaration of the method but not the
implementation then this class is abstract and can not be instantiated. Sub-classes need then to
define the methods except if they are also declared as abstract. If a class contains an abstract
method it also needs to get defined with the keyword abstract. The following example shows an
abstract class.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 15


Java full Stack Internship

Chapter 10
JAVA DATABASE CONNECTIVITY
The Java Database Connectivity (JDBC) API is the industry standard for database- independent
connectivity between the Java programming language and a wide range of databases - SQL
databases and other tabular data sources, such as spreadsheets or flat files. The JDBC API
provides a call-level API for SQL-based database access. JDBC technology allows you to use the
Java programming language to exploit "Write Once, Run Anywhere" capabilities for applications
that require access to enterprise data. With a JDBC technology-enabled driver, you can connect
all corporate data even in a heterogeneous environment.
1. JDBC drivers
There are commercial and free drivers available for most relational database servers. These
drivers fall into one of the following types:
Type 1, That calls native code of the locally available ODBC driver.
Type 2, That calls database vendor native library on a client side. This code then talks to database
over network.
Type 3, the pure-java driver that talks with the server-side middleware those then talks to
database.
Type 4, the pure-java driver that uses database native protocol

Figure 2.1 JDBC drivers

DEPT.of CSE,MRIT Mandya. 2023-24 Page 16


Java full Stack Internship
2. Functionality and implementation
JDBC allows multiple implementations to exist and be used by the same application. The API
provides a mechanism for dynamically loading the correct Java packages and registering them
with the JDBC Driver Manager. The Driver Manager is used as a connection factory for creating
JDBC connections. JDBC connections support Creating and executing statements. These may be
update statements such as SQL's CREATE, INSERT, UPDATE and DELETE, or they may be
query statements such as SELECT. Additionally, stored procedures may be invoked through a
JDBC connection. JDBC represents statements using one of the following classes-

Statement - the statement is sent to the database server each and every time.

Prepared Statement - the statement is cached and then the execution path is predetermined on
the database server allowing it to be executed multiple times in efficient manner.

Callable Statement - used for executing stored procedure son the Database. Update statements
such as INSERT, UPDATE and DELETE return an update count that indicates how many rows
were affected in the database. These statements do not return any other information. Query
statements return a JDBC row result set. The row result set is used to walk over the result set.
Individual columns in a row are retrieved either by name or by column number. There may be
any number of rows in the result set. The row result set has metadata that describes the names of
the columns and their types. There is an extension to the basic JDBC API in the javax.sql. The
method Class. forName(String) is used to load the JDBC driver class.

Example - Class.forName (sun.jdbc.odbc.JdbcOdbcDriver); Used to load the JDBC-ODBC


bridge driver.
When a Driver class is loaded, it creates an instance of itself and registers it with the Driver
Manager. Now when a connection is needed, one of the DriverManager.getConnection) methods
is used to create a JDBC connection If a database operation fails, JDBC raises a SQLException.
There is typically very little one can do to recover from such an error, apart from logging it with
as much detail as possible. It is recommended that the SQLException be translated into an
application domain exception (an unchecked one) that eventually results in a transaction rollback
and a notification to the user.

Finally to summarise, the following points can be stated-


• JDBC API provides a database programming interface for Java programs. A Java program can
send queries to a database by using the JDBC driver.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 17


Java full Stack Internship

• The java.sql package contains classes that help in connecting to a database, sending SQL
statements to the database and processing the query results.
• The Connection Object represents a connection with a database. It can be initialised using the
getConnection() method of the Driver Manager class.
• The setString() method sets the query parameters of the PreparedStatementobject.
• The Prepared Statement object allows you to execute parameterised queries. It can be
initialised using the prepareStatement() method of the Connection object.
• The execute Update () method executes the query statement present in the Prepared Statement
object and returns the number of rows affected by the query.
• The Result Set Metadata interface is used to obtain information about the columns stored in a
Result Set object.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 18


Java full Stack Internship

Chapter-11
JAVA SERVER PAGES
Java Server Pages (JSP) is a technology that helps software developers create dynamically
generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun
Microsystems [1], JSP is similar to PHP, but it uses the Java programming language. To deploy
and run Java Server Pages, a compatible web server with a servlet container, such as Apache
Tomcat or Jetty, is required.

Java Server Pages is a technology which permits software developers to create dynamic request
like HTML, XML in order to answer to client request in the net. This technology lets Java code
and definite pre-defined
Procedures to be implemented into static content. The syntax in Java Server Pages includes a
supplementary XML tag which is known s JSP actions.

It is made use to evoke the utility of the built-in functions. Moreover JSP permits to establish and
form the JSP tag libraries which operate as an extension to the standard XML or HTML tags.
These JSP tag libraries give a good technique to widen the potentiality of the Web server by
providing an independent platform's compiler compiles the JSPs into Java Servlets.

Figure 3.1 JSP

DEPT.of CSE,MRIT Mandya. 2023-24 Page 19


Java full Stack Internship

A JSP compiler may possibly create a servlet in Java code and it is later compiled by the Java
compiler. It might even directly produce the byte code for the servlet. Java Server Pages can be
examined as a high level abstraction of servlets which is practiced as an extension of the Servlet
2.1 API. Java Server Pages are HTML pages embedded with snippets of Java code. It is an
inverse of a Java Servlet.
JSPs run in two phases
• Translation Phase- In translation phase JSP page is compiled into a servlet called JSP Page
Implementation class.
• Execution Phase- In execution phase the compiled JSP is processed
The Java Server Pages and the Servlets were initially developed at Sun Microsystems. Opening
with version 1.2 of the Java Server Page specification the JSPs have been built under the Java
Community Process. There are quite a few JSP implicit objects that are represented by the JSP
container and it could be mentioned and indicated by the programmers.

Config - It gives the data of the servlet configuration.

Figure 3.2 JSP compilation

Application - Data's are shared by the servlets and Java Server Pages in the application.
Exception - Exceptions are not trapped by the codes in the application.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 20


Java full Stack Internship
Out - The data's are written with the help of JSP Writer to the response stream.
Request - Here the Hypertext Transfer Protocol request the object.
Response - Here the Hypertext Transfer Protocol response the object.
Session - It is helpful to trace the data's and information about a user from one request to another
request.
There are several actions that are performed in JSP actions. A JSP action is nothing but a XML
tags that invokes functionality of the built-in web server. Some of the JSP action is given as.
Jsp: param - It indicates a parameter which will be added in addition to the request of the
existing parameters. It is used inside the jsp: params or jsp: include, jsp: forward blocks.
Jsp: include - Java Servlet provisionally gives the request and response off to the specific Java
Server Page. The Control will later come again to the existing JSP as soon as the other JSP has
completed. With the help of this the JSP code will be distributed among several other JSPs rather
than replica.
Jsp: forward - This JSP action is used to give off the request/response to the other servlet or JSP.
The control will not come back to the existing JSP.
Jsp: plugin - The ancient version of web browsers like Internet Explorer and Netscape Navigator
use various tags to embed an applet. This action creates the definite tags that are required for a
browser to include an applet.
Jsp: fallback - This action is used to confirm that if the browser Never gives support to applets.

Figure 3.3 JSP Tag

Jsp:getProperty - It obtains a property from the specific JavaBean.


Jsp: set Property - It sets a property in the specific JavaBean

DEPT.of CSE,MRIT Mandya. 2023-24 Page 21


Java full Stack Internship

Chapter-12
SERVLET
Servlets are protocol and platform independent server-side software components, written in Java.
They run inside a Java enabled server or application server, such as the Web Sphere Application
Server. Servlets are loaded and executed within the Java Virtual Machine (JVM) of the Web
server or application server, in much the same way that applets are loaded and executed within
the JVM of the Web client.
Since servlets run inside the servers, however, they do not need a graphical user interface (GUI).
In this sense, servlets are also faceless objects.
Servlets more closely resemble Common Gateway Interface (CGI) scripts or programs than
applets in terms of functionality. AS in CGI programs, servlets can respond to user events from
an HTML request, and then dynamically construct n HTML response that is sent back to the
client.
1) The Java Servlet API
The Java Servlet API is a set of Java classes which define a standard interface between a Web
client and a Web servlet. Client requests are made to the Web server, which then invokes the
servlet to service the request through this interface.
The API is composed of two packages:
javax.servlet
javax.servlet.http
The Servlet interface class is the central abstraction of the JavaServlet API. This class
defines the methods which servlets must implement, including a service O method for the
handling of requests. The Generic Servlet class implements this interface, and defines a
generic, protocol-independent servlet To write an HTTP servlet for use on the Web, we will
use an even More specialised class of Generic Servlet called HttpServlet.HttpServlet
provides additional methods for the processing of HTTP requests such as GET (do Get
method) and POST (do Post method). Although our servlets may implement a service
method, in most cases we will implement the HTTP specific request handling methods of do
get and do Post.
2) Servlet Life Cycle
The life cycle of a servlet can be categorised into four parts:
Loading and Instantiation- The servlet container loads the servlet during startup or when the

DEPT.of CSE,MRIT Mandya. 2023-24 Page 22


Java full Stack Internship

first request is made. The loading of the servlet depends on the attribute < load-onstartup> of
Web.Xml file. If the attribute <load-on-startup> has a positive value then the servlet is load with
loading of the container otherwise it load when the first request comes for service. After load in
of the servlet, the container creates the instances of the servlet
Initialisation- After creating the instances, the servlet container calls the init() method and passes
the servlet initialisation parameters to the init() method. The init() must be called by the servlet
container before the servlet can service any request. The initialisation parameters persist until the
servlet is destroyed. The int method is called only once throughout the lite cycle of the servlet.
The servlet will be available for service if it is loaded successfully otherwise the servlet container
unloads the servlet.
Servicing the Request: After successfully completing the initialisation process, the servlet will
be available for service. Servlet creates separate threads for each request. The servlet container
calls the service() method for servicing any request. The service() method determines the kind of
request and calls the appropriate method (doGet() or doPost()) for handling the request and sends
response to the client using the methods of the response object.
Destroying the Servlet- If the servlet is no longer needed for servicing any request, the servlet
container calls the destroy 0 method. Like the init) method this method is also called only once
throughout the life cycle of the servlet. Calling the destroy method indicates to the servlet
container not to sent the any request for service and the servlet releases all the resources
associated with it. Java Virtual Machine claims for the memory associated with the resources for
garbage collection.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 23


Java full Stack Internship
Chapter-13
Project
Introduction
The Student Management System is a web-based application designed to manage student
information efficiently. This project is developed using Java, JSP, JDBC, Servlet, and Bootstrap,
providing a robust and user-friendly interface for managing student data such as student ID,
name, and marks. The application allows users to add, edit, and delete student records.

Technologies Used
1. Java: The core programming language used for backend logic.
2. JSP (JavaServer Pages): For rendering dynamic web content.
3. JDBC (Java Database Connectivity): For database interactions.
4. Servlets: For handling requests and responses.
5. Bootstrap: For a responsive and visually appealing user interface.

Application Structure
The application consists of several components, each responsible for a specific functionality:
1. Home Page:
◦ Provides a welcome message to the users.
◦ Users can navigate to different sections such as adding a new student or
displaying student details.
2. Add Student Page:
◦ A form where users can input student details like name and marks.
◦ A submit button to save the data to the database.
3. Display Student Page:
◦ Displays a list of all students with their IDs, names, and marks.
◦ Includes options to edit or delete each student record.
4. Edit Student Page:
◦ Allows users to update existing student information.
◦ Similar to the add student form but pre-filled with the selected student's data for
editing.

DEPT.of CSE,MRIT Mandya. 2023-24 Page 24


Java full Stack Internship

Database Interaction
The application uses JDBC to interact with the database. The key operations include:
1. Insert: Adding new student records.
2. Update: Modifying existing student records.
3. Delete: Removing student records.
4. Select: Fetching student records to display in the list.

User Interface:-
The application leverages Bootstrap for a clean and responsive design. Key UI components
include:
1. Navigation Bar: Provides links to the home, add student, and display student pages.
2. Forms: For adding and editing student details.
3. Tables: For displaying the list of students with edit and delete options.
Screenshots
1. Home Page:

DEPT.of CSE,MRIT Mandya. 2023-24 Page 25


Java full Stack Internship

2. Student List Page:

3. Edit Student Page:

DEPT.of CSE,MRIT Mandya. 2023-24 Page 26


Java full Stack Internship

Conclusion
During the internship, the trainee had the invaluable opportunity to learn and apply a range of
technologies including JSP, JDBC, Servlets, and Java. Through dedicated effort and hands-on
practice, the trainee successfully developed a comprehensive Student Management System. This
project served as a practical application of the theoretical knowledge gained and allowed the
trainee to understand the intricacies of web development using Java technologies.

The Student Management System project involved creating a web-based application that
efficiently manages student information. The trainee was responsible for designing and
implementing various functionalities such as adding, editing, and deleting student records, as
well as displaying the list of students in a user-friendly interface. Utilising JSP for dynamic
content rendering, JDBC for database interactions, and Servlets for request handling, the trainee
demonstrated a solid understanding of full-stack development in a Java environment.
Additionally, the integration of Bootstrap ensured the application was both responsive and
visually appealing.

As a trainee, the individual gained practical experience in key areas such as:

1. Java Programming: Strengthened core Java skills and applied object-oriented principles
in a real-world project.
2. JSP and Servlets: Developed and managed dynamic web content, gaining insights into
server-side scripting and request-response handling.
3. JDBC: Implemented database operations, enhancing understanding of SQL and database
connectivity.
4. Bootstrap: Learned to create responsive web designs, improving user experience and
interface design skills.
This internship provided a solid foundation for the trainee's future career in software
development. The hands-on experience with these technologies not only built technical
proficiency but also fostered problem-solving skills, project management, and an understanding
of the software development lifecycle

DEPT.of CSE,MRIT Mandya. 2023-24 Page 27


Java full Stack Internship

References
[1.] www.udemy.com
[2.] Programming in JAVA (Student Learning Booklet of Road Ahead Technology)
[3.] https://www.mindsmapped.com/java-advantages-and-disadvantages/

DEPT.of CSE,MRIT Mandya. 2023-24 Page 28

You might also like