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.
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
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