SlideShare a Scribd company logo
1 of 20
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 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.
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

What's hot (20)

Dom
DomDom
Dom
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java features
Java featuresJava features
Java features
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Java Beans
Java BeansJava Beans
Java Beans
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Asp.net mvc basic introduction
Asp.net mvc basic introductionAsp.net mvc basic introduction
Asp.net mvc basic introduction
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Servlet
Servlet Servlet
Servlet
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 

Similar to Java web application development

Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generationEleonora Ciceri
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...MathivananP4
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdfArumugam90
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptxMattMarino13
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxkarthiksmart21
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSPGary Yeh
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteTushar B Kute
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesbharathiv53
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIPRIYADARSINISK
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.pptsindhu991994
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 

Similar to Java web application development (20)

AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generation
 
Servlets
ServletsServlets
Servlets
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
 
BITM3730Week12.pptx
BITM3730Week12.pptxBITM3730Week12.pptx
BITM3730Week12.pptx
 
Servlets
ServletsServlets
Servlets
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptx
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responses
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, API
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 

Recently uploaded

Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20rejz122017
 
ECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentationECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentationFahadFazal7
 
Using AI to boost productivity for developers
Using AI to boost productivity for developersUsing AI to boost productivity for developers
Using AI to boost productivity for developersTeri Eyenike
 
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathphntsoaki
 
"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXR"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXRMegan Campos
 
The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...Kayode Fayemi
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxthusosetemere
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESfuthumetsaneliswa
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.thamaeteboho94
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdfNancy Goebel
 
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNLITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNtntlai16
 
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...ZurliaSoop
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityHung Le
 

Recently uploaded (19)

Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
 
Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20
 
ECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentationECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentation
 
Using AI to boost productivity for developers
Using AI to boost productivity for developersUsing AI to boost productivity for developers
Using AI to boost productivity for developers
 
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth death
 
"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXR"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXR
 
The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...The Concession of Asaba International Airport: Balancing Politics and Policy ...
The Concession of Asaba International Airport: Balancing Politics and Policy ...
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf2024 mega trends for the digital workplace - FINAL.pdf
2024 mega trends for the digital workplace - FINAL.pdf
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORNLITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
 
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait Cityin kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
 

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.
  • 4.
  • 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.
  • 11.
  • 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("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");
  • 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