forward and sendRedirect

Whenever there is a request from the client (or browser) to the server, the server container creates two objects 1. request 2. response and pass these objects to the servlet along with other parameters if needed.    S.No.  RequestDispatcher.forward  HttpServletResponse.sendRedirect  1. the request is forwarded to other resource(say B) in the same context, B does some ...

flushing buffer means?

Flushing means the data processed so far can go to the client even if the rest of the page isn’t done yet. It’s useful when you have a lot of data to send like in a download. flush=true : means send to client flush=false : means wait.

Error and Exceptions

Error and Exceptions
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. An Error is represented by an object of class Error. But an error is too severe for a program to handle mostly abnormal conditions, the program must stop running. Example : ...

equals() method

When you really need to know if two references are identical, use ==. But when you need to know if the objects themselves (not the references) are equal, use the equals() method(which you may need to override).Comparing two object references using the == operator evaluates to true only when both references refer to the same ...

Dynamic and Static binding

Dynamic binding means the runtime finds the type of an object (probably from its Class<T> object) and uses that type to look for the types of methods invoked. It applies to overridden class members. And the only kind of class member you can override is an instance method.   Static binding means the compiler finds the type of ...

Difference between sleep(), suspend() and wait() 8

The question that was popped-up to us was what is the difference between suspend(), wait() and sleep() (methods of Java)? Though minute, there is a subtle difference among the three. Here’s how: sleep() is a static method that is used to send the calling thread into a non-runnable state for the given duration of time. The ...

Difference between finally and finalize

finally block is used in exception handling.   try {         //code that may or may not throw exception, goes here } catch(Exception e) {     //handling exception } finally {     //Code goes here }   The finally block executes after a section of code in a method. For example, if you have code that might ...

Database Connection Pooling 2

In software engineering, a connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to ...

Daemon Threads

A daemon thread is a thread, that does not prevent the JVM from exiting when the program finishes but the thread is still running. An example for a daemon thread is the garbage collection.     Daemon threads are like a service providers for other threads or objects running in the same process as the ...

Constructors and Methods

A constructor is a special method (not appropriate to call it a method but for the sake of analogy) whose task is to initialize the object of its class.It is special because its name is the same as the class name.They do not have return types, not even void and therefore they cannot return values. ...