SlideShare a Scribd company logo
2
Most read
11
Most read
19
Most read
By
Ritik Rathaur
• If you develop a web application you typically put your web application on
a dedicated server . The web application runs on the server and people can
access it there. The server is either a real machine or a virtual server which
is basically a machine which is separated by software into smaller machines.
• It is possible to use your local computer as a server, but usually you want to
have a fixed server which runs 24 hours per day, 7 days per week so that
web clients can always reach your server under a pre-defined address.
• For example, blog.vogella.com contains the vogella blog. This blog is a web
application powered by WordPress which is a web application written in the
server-side scripting language PHP.
• A Java web application is a collection of dynamic resources such as
Servlets, JavaServer Pages, Java classes and jars and static resources HTML
pages and pictures. A Java web application can be deployed as a WAR (Web
ARchive) file.
• A WAR file is a zip file which contains the complete content of the
corresponding web application.
Java web application development
• Java Servlets are programs that run on a Web or Application server and act
as a middle layer between a requests coming from a Web browser or other
HTTP client and databases or applications on the HTTP server.
• Using Servlets, you can collect input from users through web page forms,
present records from a database or another source, and create web pages
dynamically.
• The following diagram shows the position of Servlets in a Web
Application.
A servlet life cycle can be defined as the entire process from its creation
till the destruction. The following are the paths followed by a servlet.
• The servlet is initialized by calling the init() method.
• The servlet calls service() method to process a client's request.
• The servlet is terminated by calling the destroy()method.
• Finally, servlet is garbage collected by the garbage collector of the
JVM.
Import javax.servlet.http.*;
Import java.io.*;
public class CountServlet extends HttpServlet
{
Int count;
public void init()
{
count==0;
}
Public void service(HttpServletRequest req,HttpServletResponse resp)throws IOException
{
count++;
printWriter pw=res.getWriter();
pw.println(“number of click”+count)
}
public void destroy()
{
count=0;
}
}
• JavaServer Pages is a technology for developing Webpages that supports
dynamic content. This helps developers insert java code in HTML pages by
making use of special JSP tags, most of which start with <% and end with
%>.
• A JavaServer Pages component is a type of Java servlet that is
designed to fulfill the role of a user interface for a Java web
application. Web developers write JSPs as text files that combine
HTML or XHTML code, XML elements, and embedded JSP actions
and commands.
• Using JSP, you can collect input from users through Webpage forms,
present records from a database or another source, and create
Webpages dynamically.
The JSP pages follows these phases:
• Translation of JSP Page
• Compilation of JSP Page
• Classloading (class file is loaded by the classloader)
• Instantiation (Object of the Generated Servlet is created).
• Initialization ( jspInit() method is invoked by the container). ‘
• Reqeust processing ( _jspService() method is invoked by the container).
• Destroy ( jspDestroy() method is invoked by the container).
• Note: jspInit(), _jspService() and jspDestroy() are the life cycle methods of
JSP.
Java web application development
Comment Tag: <%-- --%>
Declaration Tag: <%! %>
Scrptlet Tag: <% %>
Output or Expression Tag: <%= %>
Directive Tag: <%@ Page Directive%>
<%@ Include %>
<%@ TagLib%>
<Html>
<%! String res=‘’’; %>
<%! String s1=request.getParameter(“txt1”);
S2=request.getParameter(“txt2”);
If(s1!==num && s2!==num)
{
int a=Integer.parseInt(s1);
res=“Result is”+(a+b);
} <%>
<body>
<table>
<form>
<tr>
<td>Integer 1</td>
<td><Input type=“text” name=“txt1”></td>
</tr>
<tr>
<td>Integer 2</td>
<td> ><Input type=“text” name=“txt1”></td>
</tr>
</form>
</table>
</body>
</HTML>
JDBC stands for Java Database Connectivity, which is a standard Java
API for database independent connectivity between the Java
programming language and a wide range of databases. The JDBC
library includes APIs for each of the tasks commonly associated with
database usage:
• Making a connection to a database
• Creating SQL or MySQL statements
• Executing that SQL or MySQL queries in the database
• Viewing & Modifying the resulting records
The JavaMail API provides a platform-independent and
protocol-independent framework to build mail and
messaging applications.
• Sending Email
• Sending email through Gmail server
• Receiving Email
• Sending HTML content
import java.io.IOException;
import java.net.InetAddress;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns = {"/Signup"})
public class Signup extends HttpServlet {
Connection c;
Statement st;
String p;
String ip
@Override
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException
{
p=req.getServerPort()+"";
try{
String s1 = req.getParameter("Fname");
String s2 = req.getParameter("Lname");
String s3 = req.getParameter("Email");
String s4 = req.getParameter("Mno");
String s5 = req.getParameter("Birth");
String s6 = req.getParameter("pass");
String s7 = req.getParameter("Confirmpass");
String tempid=getTempid();
Class.forName("com.mysql.jdbc.Driver");
c = DriverManager.getConnection("jdbc:mysql://localhost:3306/helodb", "root", "");
c.setAutoCommit(false);
st = c.createStatement();
String path=getServletContext().getRealPath("/");
st.executeUpdate("insert into regist values('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 + "','" + s5 + "','" + s6 + "','" + s7 +
"','N',’)");
public boolean sendMail(String email)
{
try
{
InetAddress add=InetAddress.getLocalHost();
String ip=add.getHostAddress();
String host="smtp.gmail.com";
String user="rathaurritik8960";
String pass="123456king";
String port="465";
Properties pros=new Properties();
pros.put("mail.smtp.host", host);
pros.put("mail.smtp.user",user);
pros.put("mail.smtp.password", pass);
pros.put("mail.smtps.auth",true);
Session ses=Session.getDefaultInstance(pros);
MimeMessage mes=new MimeMessage(ses);
mes.setSubject("Confirmation mail from BigSeller");
mes.setFrom(new InternetAddress("rathaurritik8960@gmail.com"));
mes.setRecipient(Message.RecipientType.TO,new InternetAddress(email));
mes.setContent("Dear Sir/ma'am;<br> Greetings from BigSeller!!!!<br><br><br>"
+ "Please click on or copy paste below link to verify yourself and purchase most valuable Item
on portal<br>http://"+ip+":"+p+"/WebApp3/verify?Email="+tempid+"<br><br>Warms Regards, <br> BigSeller",
"text/html");
Transport trans=ses.getTransport("smtps");
trans.connect(host,user,pass);
trans.sendMessage(mes,mes.getAllRecipients());
c.commit();
st.close();
c.close();
}
catch(Exception e1)
{
try
{
c.rollback();
st.close();
c.close();
}
catch(Exception e2)
{
}
return false;
}
return true;
}
}
Security is an important aspect of applications that transport sensitive data over
the Internet. Because of this requirement, the servlet specification requires
servlet containers to provide implementations of basic and digest
authentication, as defined in the HTTP/1.1 specification. Additionally, servlet
containers must provide form-based security that allows developers to control
the look and feel of login screens

More Related Content

PPT
Introduction to .NET Framework
PPT
C#.NET
PPTX
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
PPTX
LINQ in C#
PPT
Java interfaces
PPT
Servlet life cycle
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PPTX
Interface in java
Introduction to .NET Framework
C#.NET
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
LINQ in C#
Java interfaces
Servlet life cycle
Basic Concepts of OOPs (Object Oriented Programming in Java)
Interface in java

What's hot (20)

PPTX
Design Patterns - General Introduction
PPSX
JDBC: java DataBase connectivity
PPSX
Introduction to .net framework
PPTX
Core java complete ppt(note)
PPTX
Servlets
PPTX
Basics of Object Oriented Programming in Python
PPT
friend function(c++)
PPTX
Introduction to Java -unit-1
PDF
JSP Technology I
PPTX
Decomposition using Functional Dependency
PPTX
Tcp/ip server sockets
DOCX
Uml Common Mechanism
PPTX
Data Integration and Transformation in Data mining
PPTX
Java Beans
PDF
Servlet and servlet life cycle
PPTX
Adbms 17 object query language
PPTX
Introduction to Spring Boot
PDF
Introduction to Design Pattern
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
Ajax
Design Patterns - General Introduction
JDBC: java DataBase connectivity
Introduction to .net framework
Core java complete ppt(note)
Servlets
Basics of Object Oriented Programming in Python
friend function(c++)
Introduction to Java -unit-1
JSP Technology I
Decomposition using Functional Dependency
Tcp/ip server sockets
Uml Common Mechanism
Data Integration and Transformation in Data mining
Java Beans
Servlet and servlet life cycle
Adbms 17 object query language
Introduction to Spring Boot
Introduction to Design Pattern
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Ajax
Ad

Similar to Java web application development (20)

PPT
J2EE - JSP-Servlet- Container - Components
PPTX
BITM3730Week12.pptx
PPTX
JAVA SERVER PAGES
PPT
Ppt for Online music store
PPTX
JavaScript, often abbreviated as JS, is a programming language and core techn...
PPTX
Jsp and Servlets
PPTX
JSP overview
PPTX
Server side programming
PPTX
Advance Java Topics (J2EE)
PPTX
AJppt.pptx
PPTX
java Servlet technology
PPTX
WT Unit-Vuufvmjn dissimilating Dunkirk k
PPT
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
PPTX
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
PPTX
Arpita industrial trainingppt
PPTX
servlets sessions and cookies, jdbc connectivity
PPTX
JSP- JAVA SERVER PAGES
PPTX
Core web application development
PPTX
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
PPTX
WEB TECHNOLOGY Unit-3.pptx
J2EE - JSP-Servlet- Container - Components
BITM3730Week12.pptx
JAVA SERVER PAGES
Ppt for Online music store
JavaScript, often abbreviated as JS, is a programming language and core techn...
Jsp and Servlets
JSP overview
Server side programming
Advance Java Topics (J2EE)
AJppt.pptx
java Servlet technology
WT Unit-Vuufvmjn dissimilating Dunkirk k
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
JAVA SERVLETS acts as a middle layer between a request coming from a web brow...
Arpita industrial trainingppt
servlets sessions and cookies, jdbc connectivity
JSP- JAVA SERVER PAGES
Core web application development
21CS642 Module 4_1 Servlets PPT.pptx VI SEM CSE Students
WEB TECHNOLOGY Unit-3.pptx
Ad

Recently uploaded (20)

PPTX
Non-Verbal-Communication .mh.pdf_110245_compressed.pptx
PPTX
Learning-Plan-5-Policies-and-Practices.pptx
PPTX
Self management and self evaluation presentation
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PPTX
The Effect of Human Resource Management Practice on Organizational Performanc...
PDF
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
PPTX
nose tajweed for the arabic alphabets for the responsive
PPTX
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
PDF
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
PPTX
_ISO_Presentation_ISO 9001 and 45001.pptx
PPTX
Role and Responsibilities of Bangladesh Coast Guard Base, Mongla Challenges
PPTX
Emphasizing It's Not The End 08 06 2025.pptx
PPTX
2025-08-10 Joseph 02 (shared slides).pptx
DOCX
ENGLISH PROJECT FOR BINOD BIHARI MAHTO KOYLANCHAL UNIVERSITY
PPTX
Tour Presentation Educational Activity.pptx
DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PPTX
Primary and secondary sources, and history
PDF
Instagram's Product Secrets Unveiled with this PPT
PDF
Why Top Brands Trust Enuncia Global for Language Solutions.pdf
PPTX
Tablets And Capsule Preformulation Of Paracetamol
Non-Verbal-Communication .mh.pdf_110245_compressed.pptx
Learning-Plan-5-Policies-and-Practices.pptx
Self management and self evaluation presentation
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
The Effect of Human Resource Management Practice on Organizational Performanc...
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
nose tajweed for the arabic alphabets for the responsive
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
_ISO_Presentation_ISO 9001 and 45001.pptx
Role and Responsibilities of Bangladesh Coast Guard Base, Mongla Challenges
Emphasizing It's Not The End 08 06 2025.pptx
2025-08-10 Joseph 02 (shared slides).pptx
ENGLISH PROJECT FOR BINOD BIHARI MAHTO KOYLANCHAL UNIVERSITY
Tour Presentation Educational Activity.pptx
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
Primary and secondary sources, and history
Instagram's Product Secrets Unveiled with this PPT
Why Top Brands Trust Enuncia Global for Language Solutions.pdf
Tablets And Capsule Preformulation Of Paracetamol

Java web application development

  • 2. • If you develop a web application you typically put your web application on a dedicated server . The web application runs on the server and people can access it there. The server is either a real machine or a virtual server which is basically a machine which is separated by software into smaller machines. • It is possible to use your local computer as a server, but usually you want to have a fixed server which runs 24 hours per day, 7 days per week so that web clients can always reach your server under a pre-defined address. • For example, blog.vogella.com contains the vogella blog. This blog is a web application powered by WordPress which is a web application written in the server-side scripting language PHP.
  • 3. • A Java web application is a collection of dynamic resources such as Servlets, JavaServer Pages, Java classes and jars and static resources HTML pages and pictures. A Java web application can be deployed as a WAR (Web ARchive) file. • A WAR file is a zip file which contains the complete content of the corresponding web application.
  • 5. • Java Servlets are programs that run on a Web or Application server and act as a middle layer between a requests coming from a Web browser or other HTTP client and databases or applications on the HTTP server. • Using Servlets, you can collect input from users through web page forms, present records from a database or another source, and create web pages dynamically.
  • 6. • The following diagram shows the position of Servlets in a Web Application.
  • 7. A servlet life cycle can be defined as the entire process from its creation till the destruction. The following are the paths followed by a servlet. • The servlet is initialized by calling the init() method. • The servlet calls service() method to process a client's request. • The servlet is terminated by calling the destroy()method. • Finally, servlet is garbage collected by the garbage collector of the JVM.
  • 8. Import javax.servlet.http.*; Import java.io.*; public class CountServlet extends HttpServlet { Int count; public void init() { count==0; } Public void service(HttpServletRequest req,HttpServletResponse resp)throws IOException { count++; printWriter pw=res.getWriter(); pw.println(“number of click”+count) } public void destroy() { count=0; } }
  • 9. • JavaServer Pages is a technology for developing Webpages that supports dynamic content. This helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>. • A JavaServer Pages component is a type of Java servlet that is designed to fulfill the role of a user interface for a Java web application. Web developers write JSPs as text files that combine HTML or XHTML code, XML elements, and embedded JSP actions and commands. • Using JSP, you can collect input from users through Webpage forms, present records from a database or another source, and create Webpages dynamically.
  • 10. The JSP pages follows these phases: • Translation of JSP Page • Compilation of JSP Page • Classloading (class file is loaded by the classloader) • Instantiation (Object of the Generated Servlet is created). • Initialization ( jspInit() method is invoked by the container). ‘ • Reqeust processing ( _jspService() method is invoked by the container). • Destroy ( jspDestroy() method is invoked by the container). • Note: jspInit(), _jspService() and jspDestroy() are the life cycle methods of JSP.
  • 12. Comment Tag: <%-- --%> Declaration Tag: <%! %> Scrptlet Tag: <% %> Output or Expression Tag: <%= %> Directive Tag: <%@ Page Directive%> <%@ Include %> <%@ TagLib%>
  • 13. <Html> <%! String res=‘’’; %> <%! String s1=request.getParameter(“txt1”); S2=request.getParameter(“txt2”); If(s1!==num && s2!==num) { int a=Integer.parseInt(s1); res=“Result is”+(a+b); } <%> <body> <table> <form> <tr> <td>Integer 1</td> <td><Input type=“text” name=“txt1”></td> </tr> <tr> <td>Integer 2</td> <td> ><Input type=“text” name=“txt1”></td> </tr> </form> </table> </body> </HTML>
  • 14. JDBC stands for Java Database Connectivity, which is a standard Java API for database independent connectivity between the Java programming language and a wide range of databases. The JDBC library includes APIs for each of the tasks commonly associated with database usage: • Making a connection to a database • Creating SQL or MySQL statements • Executing that SQL or MySQL queries in the database • Viewing & Modifying the resulting records
  • 15. The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. • Sending Email • Sending email through Gmail server • Receiving Email • Sending HTML content
  • 16. import java.io.IOException; import java.net.InetAddress; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = {"/Signup"}) public class Signup extends HttpServlet { Connection c; Statement st; String p; String ip
  • 17. @Override public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { p=req.getServerPort()+""; try{ String s1 = req.getParameter("Fname"); String s2 = req.getParameter("Lname"); String s3 = req.getParameter("Email"); String s4 = req.getParameter("Mno"); String s5 = req.getParameter("Birth"); String s6 = req.getParameter("pass"); String s7 = req.getParameter("Confirmpass"); String tempid=getTempid(); Class.forName("com.mysql.jdbc.Driver"); c = DriverManager.getConnection("jdbc:mysql://localhost:3306/helodb", "root", ""); c.setAutoCommit(false); st = c.createStatement(); String path=getServletContext().getRealPath("/"); st.executeUpdate("insert into regist values('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 + "','" + s5 + "','" + s6 + "','" + s7 + "','N',’)");
  • 18. public boolean sendMail(String email) { try { InetAddress add=InetAddress.getLocalHost(); String ip=add.getHostAddress(); String host="smtp.gmail.com"; String user="rathaurritik8960"; String pass="123456king"; String port="465"; Properties pros=new Properties(); pros.put("mail.smtp.host", host); pros.put("mail.smtp.user",user); pros.put("mail.smtp.password", pass); pros.put("mail.smtps.auth",true); Session ses=Session.getDefaultInstance(pros); MimeMessage mes=new MimeMessage(ses); mes.setSubject("Confirmation mail from BigSeller"); mes.setFrom(new InternetAddress("[email protected]")); mes.setRecipient(Message.RecipientType.TO,new InternetAddress(email)); mes.setContent("Dear Sir/ma'am;<br> Greetings from BigSeller!!!!<br><br><br>" + "Please click on or copy paste below link to verify yourself and purchase most valuable Item on portal<br>http://"+ip+":"+p+"/WebApp3/verify?Email="+tempid+"<br><br>Warms Regards, <br> BigSeller", "text/html");
  • 20. Security is an important aspect of applications that transport sensitive data over the Internet. Because of this requirement, the servlet specification requires servlet containers to provide implementations of basic and digest authentication, as defined in the HTTP/1.1 specification. Additionally, servlet containers must provide form-based security that allows developers to control the look and feel of login screens