Thursday, November 19, 2009
Hashmap and HashTable
Hash map allows null values but hash table accept the null values but it gives runtime exception
some important points on static and non static method overriding
a static method (in a subclass) may hide another static method (in a superclass)
a static method (in a subclass) cannot hide a non-static method (in a superclass)
a non-static method (in a subclass) may override another non-static method (in a superclass)
a non-static method (in a subclass) cannot override a static method (in a superclass)
a static method (in a subclass) cannot hide a non-static method (in a superclass)
a non-static method (in a subclass) may override another non-static method (in a superclass)
a non-static method (in a subclass) cannot override a static method (in a superclass)
Wednesday, November 11, 2009
different types of Synchronization
| ||
Types of Synchronization: 1)Method level Synchronization: A method can be Synchronized by adding a perfix word Synchronize . Here we have Parametrised Synchronization options also. example: public Synchronize void foo(){} 2)Block level Synchronization: A block can be Synchronized by adding a perfix word Synchronize . Here we have Parametrised Synchronization options also. Synchronize { } |
Types of action clases in stuts
There are fine different types of actions in the struts
i) Forward Action (to forward a request to another resource in your
application)
ii) Include Action ( To include some action )
application)
ii) Include Action ( To include some action )
You Might be wondering what the difference between Forward Action and Include
Action so here it is : The difference is that you need to use the IncludeAction
only if the action is going to be included by another action or JSP. Use
ForwardAction to forward a request to another resource in your application such
as a Servlet that already does business logic processing or even another JSP
page.
Action so here it is : The difference is that you need to use the IncludeAction
only if the action is going to be included by another action or JSP. Use
ForwardAction to forward a request to another resource in your application such
as a Servlet that already does business logic processing or even another JSP
page.
iii) Dispatch Action ( to group related actions into one class)
iv) Lookup Dispatch Action (is useful if the method name in the Action is not
driven by its name in the front end but by the Locale independent key into the
resource bundle.)
iv) Lookup Dispatch Action (is useful if the method name in the Action is not
driven by its name in the front end but by the Locale independent key into the
resource bundle.)
The difference between LookupDispatchAction and DispatchAction is that the
actual method that gets called in LookupDispatchAction is based on a lookup of a
key value instead of specifying the method name directly.
actual method that gets called in LookupDispatchAction is based on a lookup of a
key value instead of specifying the method name directly.
v) Switch Action (The SwitchAction class provides a means to switch from a
resource in one module to another resource in a different module. SwitchAction
is useful only if you have multiple modules in your Struts application. The
SwitchAction class can be used as is without extending.)
resource in one module to another resource in a different module. SwitchAction
is useful only if you have multiple modules in your Struts application. The
SwitchAction class can be used as is without extending.)
Implicit Objects in jsp
Variable | Class | Description |
---|---|---|
application | The context for the JSP page's servlet and any Web components contained in the same application. See Accessing the Web Context. | |
config | Initialization information for the JSP page's servlet. | |
exception | Accessible only from an error page. See Handling Errors. | |
out | The output stream. | |
page | The instance of the JSP page's servlet processing the current request. Not typically used by JSP page authors. | |
pageContext | The context for the JSP page. Provides a single API to manage the various scoped attributes described in Using Scope Objects . This API is used extensively when implementing tag handlers (see Tag Handlers). | |
request | subtype of javax.servlet. | The request triggering the execution of the JSP page. See Getting Information from Requests. |
response | subtype of javax.servlet. | The response to be returned to the client. Not typically used by JSP page authors. |
session | The session object for the client. See Maintaining Client State. |
Difference between ServletContext and ServletConfig
ServletContext Defines a set of methods that a servlet uses to communicate with its servlet container.
ServletConfig is a servlet configuration object used by a servlet container used to pass information to a servlet during initialization. All of its initialization parameters can ONLY be set in deployment descriptor.
The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.
You can specify param-value pairs for ServletContext object in tags in web.xml file.
The ServletConfig parameters are specified for a particular servlet and are unknown to other servlets.
The ServletContext parameters are specified for an entire application outside of any particular servlet and are available to all the servlets within that application.
ServletConfig is a servlet configuration object used by a servlet container used to pass information to a servlet during initialization. All of its initialization parameters can ONLY be set in deployment descriptor.
The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.
You can specify param-value pairs for ServletContext object in
The ServletConfig parameters are specified for a particular servlet and are unknown to other servlets.
The ServletContext parameters are specified for an entire application outside of any particular servlet and are available to all the servlets within that application.
what is the use of immutable String class in java?...
Immutable means not changeable. when a string is declared and initiated with some values. Afterwards whenever we will concat that string or change that string. if we r going to add more characters in that string object. it will not allow dynamic size change. to cater such problem when any change will occur in string object the object will be recreated and previous object will be destroyed and new will be created with new size to accomodate change. thats y strings are immutable in java. Mutable Objects: When you have a reference to an instance of an object, the contents of that instance can be altered Immutable Objects: When you have a reference to an instance of an object, the contents of that instance cannot be altered |
what is Factory Method
Factory method is just a fancy name for a method that instantiates objects. Like a factory, the job of the factory method is to create -- or manufacture -- objects.
Simple example for revesing a string
public static void main(String[] args) {
String text="text";
for(int i=text.length();i>0;i--){
//System.out.print(text.substring(i-1,i));
System.out.print(text.toCharArray()[i-1]);
}
}
String text="text";
for(int i=text.length();i>0;i--){
//System.out.print(text.substring(i-1,i));
System.out.print(text.toCharArray()[i-1]);
}
}
Subscribe to:
Posts (Atom)