CODE-GEEK
PROGRAMMING,INTERVIEW QUESTION
Tuesday, June 28, 2016
Friday, December 4, 2015
Friday, July 31, 2015
Spring MVC Flow Diagram
Spring MVC 3 Execution Flow
Step 1: First request will be received by DispatcherServlet
Step 2: DispatcherServlet will take the help of HandlerMapping and get to know theController class name associated with the given request
Step 3: So request transfer to the Controller, and then controller will process the request by executing appropriate methods and returns ModeAndView object (contains Model data and View name) back to the DispatcherServlet
Step 4: Now DispatcherServlet send the model object to the ViewResolver to get the actual view page
Step 5: Finally DispatcherServlet will pass the Model object to the View page to display the result.
Step 2: DispatcherServlet will take the help of HandlerMapping and get to know theController class name associated with the given request
Step 3: So request transfer to the Controller, and then controller will process the request by executing appropriate methods and returns ModeAndView object (contains Model data and View name) back to the DispatcherServlet
Step 4: Now DispatcherServlet send the model object to the ViewResolver to get the actual view page
Step 5: Finally DispatcherServlet will pass the Model object to the View page to display the result.
Monday, February 23, 2015
DIFFERENCE BETWEEN LOAD() AND GET() METHOD IN HIBERNATE
1. session.load()
--------------------
It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object.
If no row found , it will throws an ObjectNotFoundException.
2. session.get()
-------------------
It always hit the database and return the real object, an object that represent the database row, not proxy.
If no row found , it return null
--------------------
It will always return a “proxy” (Hibernate term) without hitting the database. In Hibernate, proxy is an object with the given identifier value, its properties are not initialized yet, it just look like a temporary fake object.
If no row found , it will throws an ObjectNotFoundException.
2. session.get()
-------------------
It always hit the database and return the real object, an object that represent the database row, not proxy.
If no row found , it return null
Friday, January 9, 2015
Singleton java class Example
package com.singleton.pattern;
import java.io.Serializable;
public class SingletonDemo implements Cloneable, Serializable {
private static SingletonDemo instance;
/**
* Don't remove this constructor
*/
private SingletonDemo() {
// no-operation
System.out.println("SingletonDemo() created...");
}
public static SingletonDemo getInstance() {
// double-checking solution
if (instance == null) {
synchronized (SingletonDemo.class) {
System.out.println("locked..");
if (instance == null) {
instance = new SingletonDemo();
}
}
}
return instance;
}
@Override
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
protected Object readResolve() {
return instance;
}
}
import java.io.Serializable;
public class SingletonDemo implements Cloneable, Serializable {
private static SingletonDemo instance;
/**
* Don't remove this constructor
*/
private SingletonDemo() {
// no-operation
System.out.println("SingletonDemo() created...");
}
public static SingletonDemo getInstance() {
// double-checking solution
if (instance == null) {
synchronized (SingletonDemo.class) {
System.out.println("locked..");
if (instance == null) {
instance = new SingletonDemo();
}
}
}
return instance;
}
@Override
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
protected Object readResolve() {
return instance;
}
}
Sunday, August 31, 2014
Java Interview Servlet Question
1.IN HOW MANY WAYS WE CAN DEVLOPE A SERVLET ?
2.WHAT IS THE DIFFERENCE BETWEEN ServletConfig & ServletContext ?
3.What are the Life Cycle Method of Servlet ?
4.Purpose of RequestDispatcher ?
5.Explain the purpose of Init() method & How many times it will be executed ?
6.Explain the difference between Get & Post method...
2.WHAT IS THE DIFFERENCE BETWEEN ServletConfig & ServletContext ?
3.What are the Life Cycle Method of Servlet ?
4.Purpose of RequestDispatcher ?
5.Explain the purpose of Init() method & How many times it will be executed ?
6.Explain the difference between Get & Post method...
Subscribe to:
Posts (Atom)