It2EDU

Tuesday, November 8, 2016









PMT function in Excel:


These functions are widely used in financial
transaction to find the present value and monthly payments.


Syntax for PMT function:

PMT (rate, nper, pv, [fv], [type])




Note: For a more complete description of the arguments in PMT, see
the PV function.

The PMT
function syntax has the following arguments:





·        
Rate   Required. The interest rate for the loan.


·        
Nper   Required. The total number of payments for the
loan.


·        
Pv    Required. The present value, or the total
amount that a series of future payments is worth now; also known as the
principal.


·        
Fv    Optional. The future value, or a cash
balance you want to attain after the last payment is made. If fv is omitted, it
is assumed to be 0 (zero), that is, the future value of a loan is 0.


·        
Type    Optional. The number 0 (zero) or 1 and
indicates when payments are due.

Consider a
loan amount
consider a loan with monthly payments, an
annual interest rate of 6%, a 5-year duration, a present value of $150,000
(amount borrowed) and a future value of 0 (that's what you hope to achieve when
you pay off a loan).



5 years or total number of payments 5 x 12 = 60.



Monthly payments at 5%  so use 6%12
that is 0.5%















Here it produces a negative value but treat it as positive value.



Therefore, monthly payment is 193.33.



Also we could find Nper, Rate, PV, and Fv.



To find out the Nper:







 Find out Rate:











 Find out the Present Value (PV):

















 Find out the Future Value (FV) :






































Saturday, October 29, 2016





Servlet is a java class implements server functionality. Java Servlet technology lets you define HTTP-specific
servlet classes. A servlet class extends the capabilities of servers that host
applications accessed by way of a request-response programming model. Although
servlets can respond to any type of request, they are commonly used to extend
the applications hosted by web servers. Java servlets are run inside the web
server. Servlets are used to build web applications.  
Actually Servlets are replacement of
CGI (Common gate way interfaces). In CGI every request creates an instance and
process the request.  So the server takes a lot burden and it is affected
on server efficiency and performance. 











Servlet
features and advantages:







  • Servlets are small platform independent java programs.

  • Used for developing web applications.

  • Robust, portable and secure.

  • Servlet are faster than others like CGI.

  • Servlets uses standard API that supported by many web servers.

  • Servlets executes within the address space of a web server.

  • Servlets does not create instances for each request.
















Discussion
about the servlet life cycle and methods:


The lifecycle of a servlet is controlled by the container in which the
servlet has been deployed. When a request is mapped to a servlet, the container
performs the following steps.




     
If an instance of the servlet does not exist, the web container Loads the
servlet class.


b    Creates an
instance of the servlet class.


c   
Initializes the servlet instance by calling the init method. Initialization is
covered in Creating and initializing a servlet.



2    Invokes the
service method, passing request and response objects. Service methods are
discussed in Writing Service methods.


If it needs to remove the servlet, the container finalizes the servlet by
calling the servlet’s destroy method.










The init() method:










The init() method is called during initialization phase of the servlet life
cycle. The Web container first maps the requested URL to the corresponding
servlet available in the Web container and then instantiates the servlet. The
Web container then creates an object of the ServletConfig interface, which
contains the startup configuration information, such as initialization
parameters of the servlet. The Web container then calls the init() method of
the servlet and passes the ServletConfig object to it. ServletException is thrown by init() method in the
context of web container doesn’t initialize the resources of servlet.







The service() method:








 The service() method is the
important method, it contains the operation code to process the request.

The servlet container calls the service() method to process the request and
generate response to the client. Each time the servlet receives the request and
process it and generates the response. This process is going on until it call
the destroy() method.

The service() method is breaks into doGet(),
doPost(),doDelete(),doOption(),doPut() and doTrace(). Most commonly used
methods are doGet() and doPost().

  








The destroy() method:





The destroy() method is called when we want to shut down the application.
When the destroy() method is called the servlet resources are removed from the
web container.

Servlet init() and destroy() methods called once during execution of a
servlet.









Below picture shows the servlet lifecycle:























See the below example for better understanding about servlet lifecycle
methods:



import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import
javax.servlet.http.HttpServletRequest;


import
javax.servlet.http.HttpServletResponse;


import java.io.PrintWriter;



/**

 * Servlet
implementation class ServletMethodsDemo


 */

@WebServlet("/ServletMethodsDemo")

public class ServletMethodsDemo extends HttpServlet {

      
private static final long serialVersionUID = 1L;

      


    private String name="Santosh kumar G";

   

    public void init()throws ServletException{

      
System.
out.println("init() method is executed");

    }

      


    public void destroy(){

      
System.
out.println("Destroy method executed");

    }



       /**

      
 *
@see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)


      
 */


      
protected void
doGet(HttpServletRequest
request, HttpServletResponse response) throws
ServletException, IOException {


             
//
TODO
Auto-generated method stub


             


             
//response.getWriter().append("Served
at: ").append(request.getContextPath());


             
response.setContentType("text/html");

             
PrintWriter
out =response.getWriter();

             
//to
print the content


             
out.println("<html><head>");

             
out.println("<title>Demo
Servlet(by"
);

             
out.println(name);

             
out.println(")</title>");

             
out.println("</head>");

             
out.println("<body><p>Demo
Servlet (by"
);

             
out.println(name);

             
out.println(")</p></body></html>");

             
out.close();

                          


      
}




      
/**

      
 *
@see
HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)


      
 */


      
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

             
// TODO Auto-generated method stub

             
doGet(
request, response);

      
}




}



We can override init(),destroy(),doGet() and doPost() methods in this
example.

When we start the servlet, it first calls the init method and then go to the
doGet() method and process the requests. Once the servlet instance removing
from the container destroy() method executes.