Types of Software Applications Explained
Types of Software Applications Explained
Application is a set of programs which is used to provide solutions for day-to-day life problems
E.g.: To perform the calculations developers introduces calculator
Programs: are set of instructions by which developers perform different functionalities or tasks
in an application
• Stand-Alone Application
• Web Application
• Mobile Application
• Distributed Application
Stand-alone Application:
Web Application
- The application which requires internet and browser is referred as Web Application.
- Web application does not require installation in a client machine.
- All the web applications are present in web servers.
- To develop web application, Programmers are using J2EE ( Java 2 Enterprise Edition ). i.e.
Advanced Java.
- e.g.: Amazon/Flipkart, Netflix, YouTube.
Note:
- Browser is a standalone application which is used to access web applications with the help
of internet. E.g.: Chrome, Firefox.
- J2EE is an extension of J2SE which is developed web applications, microservice, Rest API’s.
- J2EE consists of following concepts:
o Servlets
o Java Server Pages
o Hibernate framework
o Spring Framework
Servers:
Server is a machine/ Computer which is acts like a mediator between programmer & users.
- Apache Tomcat server is a web server present in the form of standalone application.
- It is an open-source server which is available for all the users.
Write a program to
1) Create an interface as a connection interface
2) In above interface. Create three abstract methods Createstatement(), preparestatement(),
preparecall().
3) Return type of CreateStatement() is statement interface, preparestatement(), is prepared
statement, preparecall() is callable statement interface.
4) In statement interface, create two methods executeQuery() and executeUpdate().
5) Extend statement to preparedStatement to callable interface.
6) Create implementation classes for connection statement , prepared statement & callable
statement interface & override executeUpdate() as well as execute query() method.
7) Create implementation class & override all the 3 methods.
8) In CreateStatement(), Create object of statement interface and return to respective method.
Perform same task for prepare statement(), preparecall().
9) Create class DriverManager, which contains static method, call it as getConnection(). The
return type of getConnection() is connection interface.
10) In getConnection(), create object of connection interface & return it to method.
11) Create a class application which consists of main method.
12) In main method, we get connection(), which will return connection object.
13) With the help of connection object, call createStatement(), which will return statement
object
14) With the help of statement object, we call executeUpadate() & executeQuery() method.
Code:
Types of components
Every web supplication has to types of components
• Front end
• Backend
Front-end
- The components which are visible to the user, are referred as frontend components. It is
also known as user interface.
- Programmers are using web technologies like HTML, CSS, JavaScript to build a front-end
component.
- E.g.: Navigation bars, forms, Videos, etc.
Back-End
- The components which are hidden from the user, are referred as backend components.
- Programmers are using J2EE to build back-End components.
- E.g.: Database, Programming languages.
- The application which consists fixed contend is referred as static web application.
- This type of applications contains only front-end components.
- E.g.: blogs.
Mobile Applications
➢ Mobile applications are those applications which can be downloaded and installed on the
mobile.
➢ Web applications are those applications which can be used directly without downloading
and installing it. We can use web browsers for using web application.
➢ Desktop application are those applications which are to be downloaded and installed on to
the computer for using it.
Distributed application:
- The applications which are divided into several parts but they are connected with each other
are referred as distributed application
- To develop these types of applications programmers are using cloud technology.
package programs;
import [Link];
if (number <1000) {
number += 1000;
}
[Link](number);
}
}
JAR File:
Maven Project:
- Maven is one of the project management tools, which can perform following tasks:
o Generation of project report
o Management of Dependencies
o Management of plugins
- By default, in maven project programmers get [Link] which represents project object
module.
- This file is used to specify dependencies.
- Dependencies are used to represent collection of jar files.
- Programmers can find the dependencies on [Link] website
- To select the dependency, programmer have to check Vulnerability and usage provided on
website
- To specify dependencies, make use of <dependencies> tag in [Link] file
API
User → Instagram
Facebook
Post Video
API
Driver
Drivers are the translators, which will convert one language to another language.
E.g.:
Compiler : Compiler is a driver, which converts high level language to numerical language
(Source code to byte code)
Interpreter: Interpreter is a driver, which converts numerical language to Binary level language
(byte code to machine code)
Decompiler: Decompiler is a driver, which converts numerical language to source code (Byte code
to Source code)
JDBC: Java Database Connectivity
As a programmer, we can’t store users’ data permanently in a java application.
Hence, store users’ data from java application to database application by using java Database
connectivity
User
JDBC Architecture:
There are 4 components in JDBC architecture
1. Java Application
2. JDBC API
3. JDBC Driver
4. Database Application
Java Application:
JDBC API:
i. DriverManager class
ii. Connection interface.
iii. Statement interface
iv. PreparedStatement interface
v. ResultSet interface
vi. CallableStatement interface
JDBC Driver:
Database Application:
It is used to store data permanently in the form of rows and columns.
URL:
URL stands for Uniform Resource Locator.
It is used to access database application in to java Application.
It contains database information like database name, protocol, host information, user information
and port number.
E.g.: For MySQL database protocol is jdbc:mysql, post information is localhost, post number is
3307 and user information is username=root & password=Saurabh@9525
jdbc:protocol//localhost:3306//J2EEa3?user=root & password=Saurabh@9525
Steps of JDBC:
There are 6 steps of JDBC:
1. Load JDBC driver.
2. Established connection from java application to database application.
3. Create a platform
4. Execution of SQL Query.
5. Process of result set
6. Close the connection.
[Link]();
}
}
}
- To establish the connection between java application and database, we have to use URL of
respective database
- Programmers are using getConnection() static method present in DriverManager class.
- For this method, programmers provide argument as an URL of database application.
- It returns Connection interface type object.
- It throws an exception i.e. SQLException. It is a checked exception present in [Link]
package
- It is a static overloaded method.
Example:
package [Link];
import [Link];
import [Link];
import [Link];
// step-2
String url = "jdbc:mysql://localhost:3306/j2ee?user=root &
password=Saurabh@9525";
Connection connection = [Link](url);
[Link]("Connection Established...");
} catch (ClassNotFoundException e) {
[Link]();
} catch (SQLException e) {
[Link]();
}
}
}
package [Link];
import [Link];
import [Link];
// step-2
String url = "jdbc:mysql://localhost:3306/j2ee";
String user = "root";
String password = "Saurabh@9525";
Connection connection = [Link](url, user,
password);
[Link]("Connection Established...");
} catch (Exception e) {
[Link]();
}
}
}
- “JDBC code contains java code as well as SQL queries, Java application can’t understand
query language.
- Hence, programmers are writing queries in the form of string, to convert this string object
into proper SQL queries, programmers are using JDBC Drivers.
- After conversion, to carry query from java application to database application, programmers
are using platform.”
Statement platform is used to carry the queries in which programmer provided the data.
E.g.: insert into emp values(1, ‘xyz’, 1000);
The query which contains runtime values, to carry these queries programmers are using
preparedStatement platform
E.g.: insert into emp values( ?, ?, ?);
package com.establish_connection;
import [Link];
import [Link];
import [Link];
package com.establish_connection;
import [Link];
import [Link];
import [Link];
} catch (Exception e) {
[Link]();
}
}
}
package com.establish_connection;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
package jdbc_application;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
try {
[Link]("[Link]");
String url = "jdbc:mysql://localhost:3306/j2ee";
String user = "root";
String password = "Saurabh@9525";
switch (choice) {
case 1:
String q1 = "insert into employee
values(06,'Vikaass','Vikaaas@[Link]',71000)";
[Link](q1);
[Link]("Employee added...");
break;
case 2:
String q2 = "delete from employee where emoid=1";
status = [Link](q2);
if (status != 0) {
[Link]("Employee deleted...");
} else {
[Link]("Error");
}
break;
case 3:
String q3 = "update employee set empname = empemail where emoid=2";
[Link](q3);
[Link]("Employee name updated...");
break;
case 4:
String q4 = "delete from employee where empemail='mayur@[Link]'";
status = [Link](q4);
if (status != 0) {
[Link]("Employee deleted...");
} else {
[Link]("Error...");
}
break;
case 5:
[Link]("enter Id to update employee : ");
int id = [Link]();
String q5 = "update employee set salary = 70000 , empname = 'Sajjad'
where emoid=" + id + "";
status = [Link](q5);
if (status != 0) {
[Link]("Employee updated...");
} else {
[Link]("Error...");
}
break;
case 6:
[Link]("enter 6 for exit ");
t = false;
break;
default:
[Link]("Something went wrong...");
}
}
} catch (Exception e) {
[Link]();
}
}
}
5. Process of result set:
Verify email:
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
// create connection
Connection con = [Link](url, user,
password);
// create platform
Statement stmt = [Link]();
// execute queries
String query = "select * from employee where
empemail='test1@[Link]'";
ResultSet rs = [Link](query);
// process result set
boolean status = [Link]();
if (status) {
[Link]("Email verified...");
} else {
[Link]("Error...");
}
} catch (Exception e) {
[Link]();
}
}
}
Email verified...
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
try {
// load driver
[Link]("[Link]");
String url = "jdbc:mysql://localhost:3306/j2ee";
String user = "root";
String password = "Saurabh@9525";
// create connection
Connection con = [Link](url, user, password);
// create platform
Statement stmt = [Link]();
// execute queries
[Link]("Enter name and id for searching... ");
String name = [Link]();
int id = [Link]();
ResultSet rs = [Link](query);
// process result set
boolean status = [Link]();
if (status) {
[Link]("User Present in database...");
} else {
[Link]("Error...");
}
} catch (Exception e) {
[Link]();
}
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
try {
// load driver
[Link]("[Link]");
String url = "jdbc:mysql://localhost:3306/j2ee";
String user = "root";
String password = "Saurabh@9525";
// create connection
Connection con = [Link](url, user, password);
// create platform
Statement stmt = [Link]();
// execute queries
[Link]("Enter name and id for searching... ");
String name = [Link]();
int id = [Link]();
ResultSet rs = [Link](query);
// process result set
if ([Link]()) {
[Link]("User Present in database...");
String ename = [Link]("empname");
[Link]("Name = "+ ename);
int eid = [Link]("emoid");
[Link]("ID = "+ eid);
double sal = [Link]("salary");
[Link]("Salary = "+ sal);
} else {
[Link]("No data found...");
}
// close the connection
[Link]();
[Link]();
} catch (Exception e) {
[Link]();
}
}
}
- To assign the values to placeholder programmers are using setter method respective with
datatype of value.
- e.g.:
String name = [Link]();
[Link](1, name);
Multi-threaded:
Multiple users can access at the same time.
Session:
It is a particular time of interval given by programmer to the user to perform specific task
Servlet chaining
Request Dispatcher
ServletRequest (I)
setAttributes(indentifier, data)
[Link](“number”, 10)
double – Double
What is servlet ?
- Servlet is an interface present in [Link] package
- It is a container present in server.
- It is used to develop dynamic web pages as well as web applications.
- It is used to connect front end of an application with backend of an application.
- We have two types of servlet classes
o Generic servlet
o Http Servlet
- Servlet interface consists following methods.
o Init()
o Destroy()
o getServletInfo()
o getServletConfig()
o service()
- Generic servlet implements - Init() , destroy(), getServletConfig(), getServletInfo() methods
from servlet interface
- Service() method is not implemented because it is used to write code to handle user request
- HttpServlet class extends generic servlet
- Note: [Link] package is not present in JRE system library hence programmer have
to provide dependency of servlet API.
- By using servlets programmers can provide two features for an application
o Multi-threaded
o Session
- To fetch the data from URL or HTML form, programmers are using getParameter() method
present in ServletRequest Interface.
- For above method provide argument as key of URL parameter or name of input box.
- Return type of above method is string.
- It is used to take input from an user while sending get request, it is present in the form of
key-value pair.
- Programmer can provide this URL parameters by using HTML form with input box.
- Syntax: [Link]
- While working with HTML form name of input box represented as a key and data entered
in input box represented as value.
- To send the request by using HTML form, programmers are using action attribute with form
tag and provide value as Servlet class map URL.
- Then create submit button in a HTML form.
What is HttpServlet ?
request
3. Get request displays user’s data 3. Post request Hides user’s data in
in URL URL
4. We can send less information using get 4. By using post request we can send
request because, data is transferred in large amount of information because
URL data is not
sent by using URL
GenericServlet HttpServlet
1. GenericServlet implements HttpServlet extends Generic servlet
servlet interface
2. GenericServlet is protocol HttpServlet is Protocol dependant
independant
3. Generic servlet supports only HttpServlet supports multithreaded as well
multithreaded feature as session feature
4. Generic servlet does not support HttpServlet supports sendRedirect
sendRedirect method method
5. In generic servlet service method In HttpServlet service method is a
is an abstract method complete method.
6. GenericServlet Does not support HttpServlet supports Sessions
Sessions
- When one servlet class will communicate with other resources like html file
o ,jsp file, other servlet classes is referred as servlet chaining.
- The main purpose of servlet chaining is linking one functionality of an application to
other functionality for sequential flow of execution.
- Programmer have two approaches to perform servlet chaining.
o By using RequestDispatcher interface
o By using sendRedirect method
- It is used to perform servlet chaining with the resiources resent in the project or ottside
the project.
- Programmers can use this sendRedirect() method only with HttpServlet class
- This method is present in HttpServlet Interface
- It provides final response to the user.
- It will change the url for redirected request.
- Programmers can provide arguments as Html file name, JSP file name and Servlet class
URL as well as URL of external resources.
- To transfer data from servlet to another servlet or JSP file, programmers prefer
“SetAttribute()” method.
- For above method programmer have to pass 2 arguments,
o Identifier
o Data
- Set attribute method supports the servlet chaining performed by using RequestDispatcher
interface.
- It will upcast data to object class.
- To access transferred data in requested resources programmers are using “getAttribute()”
method.
- setAttribute() and getAttribute(), both the methods are present in ServletRequest interface.
What is session?
Ans:
- Session is a time interval provided by programmer to the user for performing a respective
task.
- It is also a time interval between login and logout.
- It is an object, created by web container and present in server.
- When user logged in an application, then programmer have to collect user data from
database and store it in a session object.
- If in further process, programmer requires user data then he will access it form session
instead of database .
- To access session object, call getSession() method from HttpServlet Request Interface, it
returns HttpSession type object.
- HttpSession is an interface.
- To store the data in a session object, make use of setAttribute() method present in
HttpSession Interface.
- To access this data in a servlet class, make use of getAttribute() method present in
HttpSession Interface.
- To provide the time interval, make use of setMaxInactiveInterval() method.
- To close the session make use invalidate() method.
- Programmers can provide session feature for an application by using HttpServlet class.
- After completion of time interval, data will get removed from session object.
Explain JSP.
Ans:
<%
For(Employee e1 : emp){
%>
<label>Employee Id :</label>
<label>Employee Name :</label>
<label>Employee Email :</label>
<label>Employee Salary :</label>
<label>Employee Mobile :</label>
<%
}
%>
</form>