Advance Java provides some advance topics in java programming language. Some Advance Java topics are define given below:
A Servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although it can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.
Generic Servlet Class Contains Five Methods
- init() method- Init() is called only once by the servlet container in its whole lofecycle the life of a servlet. The init() method takes a ServletConfig object that contains the initialization parameters and servlet's configuration and throws a ServletException if an exception has occurred.
- Service() method - This method defined as public void service as (ServletRequest req, ServletResponse res) which throws ServletException, as IOException .If once the servlet starting getting the requests, the service() method is called by the servlet container to respond.
- getservlet config()- This method is defined as public ServletConfig getServletConfig() this method contain initialization and startup of the servlet and returns the Servlet Config object.
- getservlet info()- This method is defined as public String getServletInfo() The information about the servlet is returned by this method like version, author etc. This method returns a string which should be in the form of plain text and not any kind of markup.
- destroy()- This method is defined as public destroy().this method is called when want to close the servlet.
Life Cycle of Servlet
The life cycle of a servlet is controlled by the container in which the servlet has been deployed. The life cycle of a servlet can be categorized into four parts
- Loading and instantiation -The servlet container loads the servlet during startup or when the first request is made . After loading of servlet container create the instance of the servlet.
- Initialization:-When creating the instances,after that the servlet container calls the init() method .then passes the servlet initialization parameters to the init() method. init() method is called once through out the life cycle of servlet.
- Servicing the request -After successfully initialization ,servlet container call the service method for servising any request. The service() method determines the kind of request and calls the appropriate method (doGet() or doPost()) for handling the request and sends response to the client using the methods of the response object.
- The servlet Destroying -If the servlet is no longer required for servicing any request, the servlet container will calls the destroy() method .
Advantages of Servlet
Java servlet provide various advantages to build a server side programming. Following are the advantages of java
- Portable- As servlets are written in java and follow APIs of java so they are very high portable over operating systems and serve implementations.
- Efficient- As compared to CGI applications servlet is more efficient.
- Extensibility-The servlet API is designed in such a way that it can be easily extensible. As for now the servlet API support Http Servlets, but in later it can be extended for another type of servlet
The detail description of servlet is given in the below link of Servlet Basic with example
Hibernate is a java package that makes it easy to work with relational database. Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database Hibernate provides a solution to map database tables to a class. It copies the database data to a class. In the other direction it supports to save objects to the database.
In this process the object is transformed to one or more tables. Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions. The primary feature of hibernate is mapping from java classes to database tables and from java data types to Sql data types.
Hibernate architecture has three important components.
- Connection management: Connection management efficiently manage the data of data base. Data base connection is the very expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.
- Transaction management: This management service provide the ability to the user to execute more than one database statements at a time.
- Object relational mapping: bject relational mapping is the technique of mapping the data from object model to the relational data model. This part of management is used to insert data ,update data ,select data, and delete the records from the table. In case of connection management and Transaction management hibernate lacks in performance and capabilities but it is very good tool as far as object relational mapping is concern.
The detail description of hibernate is given in the below link of Hibernate Basic with example
Spring Framework is a Java platform that provides comprehensive infrastructure support for developing Java applications. Spring handles the infrastructure so you can focus on your application.
Spring enables you to build applications from “plain old Java objects” (POJOs) and to apply enterprise services non- invasively to POJOs. This capability applies to the Java SE programming model and to full and partial Java EE. Spring Framework provide the facility to create high performing, easily testable, reusable code.
Need of the Spring?
Spring having much of demand because of the following 3 reasons as
- Simplicity: Spring framework is simple because as it is non-invasive, POJO and POJI model.
- Testability: Writing the spring application, server [Container] is not mandatory, spring has it own container to run the applications.
- Loose Coupling: In spring objects are loosely coupled, this is the core concept of spring framework.
The detail description of spring is given in the below link of Spring Basic with example
Struts is a Frameworks which is an implementation of MVC-2 at server side. Struts1.3 have many advantages over the standard servlet and JSP API alone. Apache Struts 1.3 is the most famous, classic and Model-View-Controller (MVC) web application framework. As we said earlier, Struts 2 is n’t just a new release of the older Struts 1 framework. A web application can interact with different databases and business logic.
Advanages of strut framework
- ActionForm Beans:- When we are using JSP to send form data we have use property="*" with jsp:setProperty .This will automatically populate data a JavaBean component based on incoming request parameters. Unfortunately there is no any standard API throught wich we can do this into serevlets. Apache Struts extends this capability to Java code and adds in several useful utilities, all of which serve to greatly simplify the processing of request parameters.
- Struts-Tags Library:- Apache Struts provides a set of Bean tags (bean:write, in particular) that let us easily output the properties of JavaBeans components.Apache Struts provides a set of HTML Tags to create HTML forms that are associated with JavaBeans components. This bean/form association serves two useful purposes: It lets you get initial form-field values from Java objects.It lets you redisplay forms with some or all previously entered values intact.
- Fast Deployment:- In struts 1.3,development time can be significantly reduced.
- Advantage Utilities:- Struts1.3 provides lots of utilities derived from Apache commons to make our life easier like ready made Form Beans for request parameters,Validation controls and Custom tags
The detail description of strut is given in the below link of Strut Basic with example
Web Services are self-contained, modular, distributed, dynamic applications that can be described, published, located, or invoked over the network to create products, processes, and supply chains. Web services are developed on the basis of open standards, that's are TCP/IP, HTTP, Java, HTML, and XML.
Web Services can convert application into a Web-application that makes it available over the internet. It uses a standardized XML messaging system. In web environment XML is used to encode all communications to a web service. they are
- Is available over the Internet or private (intranet) networks.
- Uses a standardized XML messaging system.
- Is not tied to any one operating system or programming language.
- Is self-describing via a common XML grammar.
- Is discoverable via a simple find mechanism.
JSP is one of the most powerful, easy-to-use, and fundamental tools in a Web-site developer's toolbox. JSP combines HTML and XML with Java TM servlet (server application extension) and JavaBeans technologies to create a highly productive environment for developing and deploying reliable, interactive, high-performance platform-independent Web sites.
JSP facilitates the creation of dynamic content on the server. It is part of the Java platform's integrated solution for server-side programming, which provides a portable alternative to other server-side technologies, such as CGI. JSP integrates numerous Java application technologies, such as Java servlet, JavaBeans, JDBC, and Enterprise JavaBeans. It also separates information presentation from application logic and fosters a reusable-component model of programming.
Advantages of jsp
- Supports tag based programming.
- Strong java programming is not required.so,it is suitable for non-java programmers
- It gives 9 no of implicit objetcs and we can use them directly with additional code to access them.
- It allows to seperate presentation logic(html/code) from business logic(java code) exceptional handling is optional.
- It increases the readibility of code because of tags modifications will be reflected without re-compliation and re-loading
- It gives built-in JSP tags and allows to develop custom JSP tags and to use third party supplied JSP tags
- Its easy to learn and easy to apply.
- It explore the Java Virtual Machine (JVM).
- Learn code optimization techniques
- Explain the effect of OO design on software performance.