To format a currency value we use NumberFormat.getCurrencyInstance().
To get default Locale’s currency call NumberFormat.getCurrencyInstance() method.
In getCurrencyInstance() method we can give local to get the currency of the particular locale. Continue reading
Servlets follow three phase life cycle initialization,service and destruction.
1) init() method :
1) init() method : init method is called when the servlet is first created.
2) init() method is called exactly once after the instantiating Servlet.
3) init() method is used to write initialization code such as loading database drivers and initialization values so on.
4) When invoking this method servlet container passes a Servlet-Config.
5) One of the most important and common task that init() method performs is reading server specific initialization parameters.
6) The init method is important because the servlet container passes a ServletConfig object, which contains the configuration values given in the web.xml file.
Signature : public void init(ServletConfig servletConfig) throws ServletException
init() method can throw servlet exception.When init() method throws Servlet exception servlet container does not executes service() method.
servletException is also thrown when the method does not return with in the time period.
Explain Servlet api and its methods ?
1) All Servlets must implement javax.servlet.Servlet interface either directly or indirectly.
2) Servlet container will create an instance of Servlet class and uses it to handle incoming requests.
3) Servlet interface defines methods that all servlets must implement.
4) Servlet class defines a contract between Servlet and Servlet container.
What are Servlets ?
1) Java Servlets are efficient and powerful solution given by sun for creating dynamic content for the web.
2) Servlets are the main and central processing unit for web application.
3) Java Servlets are designed to respond with dynamic content to client requests. Continue reading