SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycleDhruvin Nakrani
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Peter R. Egli
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.netDeep Patel
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVAJalpesh Vasa
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 
servlet in java
servlet in javaservlet in java
servlet in javasowfi
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android Aakash Ugale
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptVMahesh5
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETRajkumarsoy
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in javaCPD INDIA
 
Databind in asp.net
Databind in asp.netDatabind in asp.net
Databind in asp.netSireesh K
 

Was ist angesagt? (20)

Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Java rmi
Java rmiJava rmi
Java rmi
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
servlet in java
servlet in javaservlet in java
servlet in java
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
OOP java
OOP javaOOP java
OOP java
 
Java RMI
Java RMIJava RMI
Java RMI
 
Databind in asp.net
Databind in asp.netDatabind in asp.net
Databind in asp.net
 

Ähnlich wie Java web application development

Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
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
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
 

Ähnlich wie Java web application development (20)

Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
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
 
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
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 

Kürzlich hochgeladen

proposal kumeneger edited.docx A kumeeger
proposal kumeneger edited.docx A kumeegerproposal kumeneger edited.docx A kumeeger
proposal kumeneger edited.docx A kumeegerkumenegertelayegrama
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRachelAnnTenibroAmaz
 
cse-csp batch4 review-1.1.pptx cyber security
cse-csp batch4 review-1.1.pptx cyber securitycse-csp batch4 review-1.1.pptx cyber security
cse-csp batch4 review-1.1.pptx cyber securitysandeepnani2260
 
Chizaram's Women Tech Makers Deck. .pptx
Chizaram's Women Tech Makers Deck.  .pptxChizaram's Women Tech Makers Deck.  .pptx
Chizaram's Women Tech Makers Deck. .pptxogubuikealex
 
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRRsarwankumar4524
 
Application of GIS in Landslide Disaster Response.pptx
Application of GIS in Landslide Disaster Response.pptxApplication of GIS in Landslide Disaster Response.pptx
Application of GIS in Landslide Disaster Response.pptxRoquia Salam
 
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptxerickamwana1
 
GESCO SE Press and Analyst Conference on Financial Results 2024
GESCO SE Press and Analyst Conference on Financial Results 2024GESCO SE Press and Analyst Conference on Financial Results 2024
GESCO SE Press and Analyst Conference on Financial Results 2024GESCO SE
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEMCharmi13
 
Internship Presentation | PPT | CSE | SE
Internship Presentation | PPT | CSE | SEInternship Presentation | PPT | CSE | SE
Internship Presentation | PPT | CSE | SESaleh Ibne Omar
 
A Guide to Choosing the Ideal Air Cooler
A Guide to Choosing the Ideal Air CoolerA Guide to Choosing the Ideal Air Cooler
A Guide to Choosing the Ideal Air Coolerenquirieskenstar
 
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxEngaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxAsifArshad8
 
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...Sebastiano Panichella
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...漢銘 謝
 
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunity
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunityDon't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunity
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunityApp Ethena
 
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Sebastiano Panichella
 
General Elections Final Press Noteas per M
General Elections Final Press Noteas per MGeneral Elections Final Press Noteas per M
General Elections Final Press Noteas per MVidyaAdsule1
 

Kürzlich hochgeladen (17)

proposal kumeneger edited.docx A kumeeger
proposal kumeneger edited.docx A kumeegerproposal kumeneger edited.docx A kumeeger
proposal kumeneger edited.docx A kumeeger
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
 
cse-csp batch4 review-1.1.pptx cyber security
cse-csp batch4 review-1.1.pptx cyber securitycse-csp batch4 review-1.1.pptx cyber security
cse-csp batch4 review-1.1.pptx cyber security
 
Chizaram's Women Tech Makers Deck. .pptx
Chizaram's Women Tech Makers Deck.  .pptxChizaram's Women Tech Makers Deck.  .pptx
Chizaram's Women Tech Makers Deck. .pptx
 
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
 
Application of GIS in Landslide Disaster Response.pptx
Application of GIS in Landslide Disaster Response.pptxApplication of GIS in Landslide Disaster Response.pptx
Application of GIS in Landslide Disaster Response.pptx
 
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx
05.02 MMC - Assignment 4 - Image Attribution Lovepreet.pptx
 
GESCO SE Press and Analyst Conference on Financial Results 2024
GESCO SE Press and Analyst Conference on Financial Results 2024GESCO SE Press and Analyst Conference on Financial Results 2024
GESCO SE Press and Analyst Conference on Financial Results 2024
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEM
 
Internship Presentation | PPT | CSE | SE
Internship Presentation | PPT | CSE | SEInternship Presentation | PPT | CSE | SE
Internship Presentation | PPT | CSE | SE
 
A Guide to Choosing the Ideal Air Cooler
A Guide to Choosing the Ideal Air CoolerA Guide to Choosing the Ideal Air Cooler
A Guide to Choosing the Ideal Air Cooler
 
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxEngaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
 
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...Testing with Fewer Resources:  Toward Adaptive Approaches for Cost-effective ...
Testing with Fewer Resources: Toward Adaptive Approaches for Cost-effective ...
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
 
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunity
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunityDon't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunity
Don't Miss Out: Strategies for Making the Most of the Ethena DigitalOpportunity
 
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
Testing and Development Challenges for Complex Cyber-Physical Systems: Insigh...
 
General Elections Final Press Noteas per M
General Elections Final Press Noteas per MGeneral Elections Final Press Noteas per M
General Elections Final Press Noteas per M
 

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