Number of View: 36
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.
Number of View: 29
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.
Number of View: 37
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
Number of View: 126
In java when a field is declared and not initialized,java compiler will be set the default value to the field value based on datatype of the field.Here are the list of datatypes and default values. Continue reading
Number of View: 143
Sometimes in real world a situation may arise where we can supply inputs to the application at the time of program execution.This can be done with help of command line arguments in java.
commandline arguments are the parameters that are supplied to the program at the time of execution. Continue reading
Number of View: 100
Here are some of the important features in java which are removed from c/c++ :
1) Pointers :
C++ supports pointer but java does not supports pointers.
2) Templates :
c++ supports templates but java does not supports templates. Continue reading
Number of View: 105
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space :
Problem : Whenver i run the application with tomcat server iam gettting the following exception. Continue reading
Number of View: 101
org.hibernate.MappingException: Repeated column in mapping for entity:
Number of View: 190
Explain final class variables with example in java?
1) We can declare class variable with final keyword.
2) Final class variables can be initialized in two ways:
1) At the time of declaration
2) Static Initializers Continue reading
Number of View: 105
1) Formal paramters can be declared as final .
2) A formal parameter is initialized automatically with the value of the actual parameter when the method or the constructor is invoked.
3) Therefore final formal parameter value cannot be changed inside the method’s or the constructor’s body. Continue reading