Вы находитесь на странице: 1из 117

Java Questions

Question: What is the difference between an Interface and an Abstract class?


What is the purpose of garbage collection in Java, and when is it used?
Question:
Question: Describe synchronization in respect to multithreading.
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:

Explain different way of using thread?


What are pass by reference and passby value?
What is HashMap and Map?
Difference between HashMap and HashTable?
Difference between Vector and ArrayList?
Difference between Swing and Awt?
What is the difference between a constructor and a method?
What is an Iterators?
State the significance of public, private, protected, default modifiers both
singly and in combination and state the effect of package relationships on
declared items qualified by these modifiers.
Question: What is an abstract class?
Question: What is static in java?
What is final?
Question:
Q:
What is the difference between an Interface and an Abstract class?
A: An Abstract class declares have at least one instance method that is declared
abstract which will be implemented by the subclasses. An abstract class can have
instance methods that implement a default behavior. An Interface can only declare
constants and instance methods, but cannot implement default behavior.
TOP

Q:
What is the purpose of garbage collection in Java, and when is it used?
A: The purpose of garbage collection is to identify and discard objects that are no
longer needed by a program so that their resources can be reclaimed and reused.
A Java object is subject to garbage collection when it becomes unreachable to the
program in which it is used.
TOP

Q:
Describe synchronization in respect to multithreading.
A: With respect to multithreading, synchronization is the capability to control the
access of multiple threads to shared resources. Without synchonization, it is
possible for one thread to modify a shared variable while another thread is in the
process of using or updating same shared variable. This usually leads to significant
errors.
TOP

Q:
Explain different way of using thread?
A: The thread could be implemented by using runnable interface or by inheriting from
the Thread class. The former is more advantageous, 'cause when you are going for
multiple inheritance..the only interface can help.
TOP

Q:
What are pass by reference and passby value?
A: Pass By Reference means the passing the address itself rather than passing the
value. Passby Value means passing a copy of the value to be passed.
TOP

Q:
What is HashMap and Map?
A: Map is Interface and Hashmap is class that implements that.
TOP

Q:
Difference between HashMap and HashTable?
A: The HashMap class is roughly equivalent to Hashtable, except that it is
unsynchronized and permits nulls. (HashMap allows null values as key and value
whereas Hashtable doesnt allow). HashMap does not guarantee that the order of
the map will remain constant over time. HashMap is non synchronized and
Hashtable is synchronized.
TOP

Q:
Difference between Vector and ArrayList?
A: Vector is synchronized whereas arraylist is not.
TOP

Q:
Difference between Swing and Awt?
A: AWT are heavy-weight componenets. Swings are light-weight components. Hence
swing works faster than AWT.
TOP

Q:
What is the difference between a constructor and a method?
A: A constructor is a member function of a class that is used to create objects of that
class. It has the same name as the class itself, has no return type, and is invoked
using
the
new
operator.
A method is an ordinary member function of a class. It has its own name, a return
type (which may be void), and is invoked using the dot operator.
TOP

Q:
What is an Iterators?
A: Some of the collection classes provide traversal of their contents via a
java.util.Iterator interface. This interface allows you to walk a collection of objects,
operating on each object in turn. Remember when using Iterators that they
contain a snapshot of the collection at the time the Iterator was obtained;
generally it is not advisable to modify the collection itself while traversing an
Iterator.
TOP

Q:
State the significance of public, private, protected, default modifiers both
singly and in combination and state the effect of package relationships on
declared items qualified by these modifiers.
A: public : Public class is visible in other packages, field is visible everywhere (class
must
be
public
too)
private : Private variables or methods may be used only by an instance of the
same class that declares the variable or method, A private feature may only be
accessed
by
the
class
that
owns
the
feature.
protected : Is available to all classes in the same package and also available to all
subclasses of the class that owns the protected feature.This access is provided
even to subclasses that reside in a different package from the class that owns the
protected
feature.
default :What you get by default ie, without any access modifier (ie, public
private or protected).It means that it is visible to all within a particular package.
TOP

Q:
What is an abstract class?
A: Abstract class must be extended/subclassed (to be useful). It serves as a
template. A class that is abstract may not be instantiated (ie, you may not call its
constructor), abstract class may contain static data. Any class with an abstract
method is automatically abstract itself, and must be declared as such.
A class may be declared abstract even if it has no abstract methods. This prevents
it from being instantiated.
TOP

Q:
What is static in java?
A: Static means one per class, not one for each object no matter how many instance
of a class might exist. This means that you can use them without creating an
instance of a class.Static methods are implicitly final, because overriding is done
based on the type of the object, and static methods are attached to a class, not an
object. A static method in a superclass can be shadowed by another static method
in a subclass, as long as the original method was not declared final. However, you
can't override a static method with a nonstatic method. In other words, you can't
change a static method into an instance method in a subclass.
TOP

Q:
What is final?
A: A final class can't be extended ie., final class may not be subclassed. A final
method can't be overridden when its class is inherited. You can't change value of a
final variable (is a constant).

Java Questions
Question:
Question:

What if the main method is declared as private?


What if the static modifier is removed from the signature of the main
method?
Question: What if I write static public void instead of public static void?
Q:Question:What if I do not provide the String array as the argument to the
method?
Question: What is the first argument of the String array in main method?
Question: If I do not provide any arguments on the command line, then the String
array of Main method will be empty of null?
Question: How can one prove that the array is not null but empty?
Question: What environment variables do I need to set on my machine in order to
be able to run Java programs?
Question: Can an application have multiple classes having main method?
Question: Can I have multiple main methods in the same class?
Question: Do I need to import java.lang package any time? Why ?
Question: Can I import same package/class twice? Will the JVM load the package
twice at runtime?
Question: What are Checked and UnChecked Exception?
Question: What is Overriding?
Question: What are different types of inner classes?
Q:
What if the main method is declared as private?
A: The program compiles properly but at runtime it will give "Main method not
public." message.
TOP
[ Received from Sandesh Sadhale]
Q:
What if the static modifier is removed from the signature of the main
method?
A: Program compiles. But at runtime throws an error "NoSuchMethodError".
TOP
[ Received from Sandesh Sadhale]
Q:
What if I write static public void instead of public static void?
A: Program compiles and runs properly.
[ Received from Sandesh Sadhale]

TOP

Q:
What if I do not provide the String array as the argument to the method?
A: Program compiles but throws a runtime error "NoSuchMethodError".

[ Received from Sandesh Sadhale]

TOP

Q:
What is the first argument of the String array in main method?
A: The String array is empty. It does not have any element. This is unlike C/C++
where the first element by default is the program name.
TOP
[ Received from Sandesh Sadhale]
Q:
If I do not provide any arguments on the command line, then the String
array of Main method will be empty of null?
A: It is empty. But not null.
TOP
[ Received from Sandesh Sadhale]
Q:
How can one prove that the array is not null but empty?
A: Print args.length. It will print 0. That means it is empty. But if it would have been
null then it would have thrown a NullPointerException on attempting to print
args.length.
TOP
[ Received from Sandesh Sadhale]
Q:
What environment variables do I need to set on my machine in order to
be able to run Java programs?
A: CLASSPATH and PATH are the two variables.
TOP
[ Received from Sandesh Sadhale]
Q:
Can an application have multiple classes having main method?
A: Yes it is possible. While starting the application we mention the class name to be
run. The JVM will look for the Main method only in the class whose name you have
mentioned. Hence there is not conflict amongst the multiple classes having main
method.
TOP
[ Received from Sandesh Sadhale]
Q:
Can I have multiple main methods in the same class?
A: No the program fails to compile. The compiler says that the main method is
already defined in the class.
TOP
[ Received from Sandesh Sadhale]
Q:
Do I need to import java.lang package any time? Why ?
A: No. It is by default loaded internally by the JVM.
[ Received from Sandesh Sadhale]

TOP

Q:
Can I import same package/class twice? Will the JVM load the package

twice at runtime?
A: One can import the same package or same class multiple times. Neither compiler
nor JVM complains abt it. And the JVM will internally load the class only once no
matter how many times you import the same class.
TOP
[ Received from Sandesh Sadhale]
Q:
What are Checked and UnChecked Exception?
A: A checked exception is some subclass of Exception (or Exception itself), excluding
class
RuntimeException
and
its
subclasses.
Making an exception checked forces client programmers to deal with the possibility
that
the
exception
will
be
thrown.
eg,
IOException
thrown
by
java.io.FileInputStream's
read()
method
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error
and its subclasses also are unchecked. With an unchecked exception, however, the
compiler
doesn't
force
client
programmers
either
to
catch
the
exception or declare it in a throws clause. In fact, client programmers may not
even
know
that
the
exception
could
be
thrown.
eg,
StringIndexOutOfBoundsException thrown by String's charAt() method Checked
exceptions must be caught at compile time. Runtime exceptions do not need to
be. Errors often cannot be.
TOP

Q:
What is Overriding?
A: When a class defines a method using the same name, return type, and arguments
as a method in its superclass, the method in the class overrides the method in the
superclass.
When the method is invoked for an object of the class, it is the new definition of
the method that is called, and not the method definition from superclass. Methods
may be overridden to be more public, not more private.
TOP

Q:
What are different types of inner classes?
A: Nested top-level classes, Member classes, Local classes, Anonymous classes
Nested top-level classes- If you declare a class within a class and specify the
static modifier, the compiler treats the class just like any other top-level class.
Any class outside the declaring class accesses the nested class with the declaring
class name acting similarly to a package. eg, outer.inner. Top-level inner classes
implicitly have access only to static variables.There can also be inner interfaces.
All
of
these
are
of
the
nested
top-level
variety.
Member classes - Member inner classes are just like other member methods and
member variables and access to the member class is restricted, just like methods
and variables. This means a public member class acts similarly to a nested toplevel class. The primary difference between member classes and nested top-level
classes is that member classes have access to the specific instance of the
enclosing
class.

Local classes - Local classes are like local variables, specific to a block of code.
Their visibility is only within the block of their declaration. In order for the class to
be useful beyond the declaration block, it would need to implement a
more publicly available interface.Because local classes are not members, the
modifiers
public,
protected,
private,
and
static
are
not
usable.
Anonymous classes - Anonymous inner classes extend local inner classes one
level further. As anonymous classes have no name, you cannot provide a
constructor.
Q:
Are the imports checked for validity at compile time? e.g. will the code
containing an import such as java.lang.ABCD compile?
A: Yes the imports are checked for the semantic validity at compile time. The code
containing above line of import will not compile. It will throw an error saying,can
not
resolve
symbol
symbol
:
class
ABCD
location:
package
io
import java.io.ABCD;
TOP
[ Received from Sandesh Sadhale]
Q:
Does importing a package imports the subpackages as well? e.g. Does
importing com.MyTest.* also import com.MyTest.UnitTests.*?
A: No you will have to import the subpackages explicitly. Importing com.MyTest.* will
import classes in the package MyTest only. It will not import any class in any of it's
subpackage.
TOP
[ Received from Sandesh Sadhale]
Q:
What is the difference between declaring a variable and defining a
variable?
A: In declaration we just mention the type of the variable and it's name. We do not
initialize
it.
But
defining
means
declaration
+
initialization.
e.g String s; is just a declaration while String s = new String ("abcd"); Or String s
= "abcd"; are both definitions.
TOP
[ Received from Sandesh Sadhale]
Q:
What is the default value of an object reference declared as an instance
variable?
A: null unless we define it explicitly.
TOP
[ Received from Sandesh Sadhale]
Q:
Can a top level class be private or protected?
A: No. A top level class can not be private or protected. It can have either "public" or
no modifier. If it does not have a modifier it is supposed to have a default access.If
a top level class is declared as private the compiler will complain that the "modifier

private is not allowed here". This means that a top level class can not be private.
Same is the case with protected.
TOP
[ Received from Sandesh Sadhale]
Q:
What type of parameter passing does Java support?
A: In Java the arguments are always passed by value .
[ Update from Eki and Jyothish Venu]

TOP

Q:
Primitive data types are passed by reference or pass by value?
A: Primitive data types are passed by value.
[ Received from Sandesh Sadhale]

TOP

Q:
Objects are passed by value or by reference?
A: Java only supports pass by value. With objects, the object reference itself is
passed by value and so both the original reference and parameter copy both refer
to the same object .
TOP
[ Update from Eki and Jyothish Venu]
Q:
What is serialization?
A: Serialization is a mechanism by which you can save the state of an object by
converting it to a byte stream.
TOP
[ Received from Sandesh Sadhale]
Q:
How do I serialize an object to a file?
A: The class whose instances are to be serialized should implement an interface
Serializable. Then you pass the instance to the ObjectOutputStream which is
connected to a fileoutputstream. This will save the object to a file.
TOP
[ Received from Sandesh Sadhale]
Q:
Which methods of Serializable interface should I implement?
A: The serializable interface is an empty interface, it does not contain any methods.
So we do not implement any methods.
TOP
[ Received from Sandesh Sadhale]
Q:
How can I customize the seralization process? i.e. how can one have a
control over the serialization process?
A: Yes it is possible to have control over serialization process. The class should
implement Externalizable interface. This interface contains two methods namely
readExternal and writeExternal. You should implement these methods and write
the logic for customizing the serialization process.
TOP
[ Received from Sandesh Sadhale]

Q:
What is the common usage of serialization?
A: Whenever an object is to be sent over the network, objects need to be serialized.
Moreover if the state of an object is to be saved, objects need to be serilazed.
TOP
[ Received from Sandesh Sadhale]
Q:
What is Externalizable interface?
A: Externalizable is an interface which contains two methods readExternal and
writeExternal. These methods give you a control over the serialization mechanism.
Thus if your class implements this interface, you can customize the serialization
process by implementing these methods.
TOP
[ Received from Sandesh Sadhale]
Q:
What happens to the object references included in the object?
A: The serialization mechanism generates an object graph for serialization. Thus it
determines whether the included object references are serializable or not. This is a
recursive process. Thus when an object is serialized, all the included objects are
also serialized alongwith the original obect.
TOP
[ Received from Sandesh Sadhale]
Q:
What one should take care of while serializing the object?
A: One should make sure that all the included objects are also serializable. If any of
the objects is not serializable then it throws a NotSerializableException.
TOP
[ Received from Sandesh Sadhale]
Q:
What happens to the static fields of a class during serialization? Are these
fields serialized as a part of each serialized object?
A:Yes the static fields do get serialized. If the static field is an object then it must
have implemented Serializable interface. The static fields are serialized as a part of
every object. But the commonness of the static fields across all the instances is
maintained even after serialization.
[ Received from Sandesh Sadhale]
Q:
Does Java provide any construct to find out the size of an object?
A:No there is not sizeof operator in Java. So there is not direct way to determine the
size of an object directly in Java.
TOP
[ Received from Sandesh Sadhale]
Q:
Does importing a package imports the subpackages as well? e.g. Does
importing com.MyTest.* also import com.MyTest.UnitTests.*?
A: Read the system time just before the method is invoked and immediately after
method returns. Take the time difference, which will give you the time taken by a
method for execution.

To put it in code...
long
start
=
method
long end = System.currentTimeMillis ();

System.currentTimeMillis

();
();

System.out.println ("Time taken for execution is " + (end - start));


Remember that if the time taken for execution is too small, it might show that it is
taking zero milliseconds for execution. Try it on a method which is big enough, in
the sense the one which is doing considerable amout of processing.
TOP
[ Received from Sandesh Sadhale]
Q:
What are wrapper classes?
A: Java provides specialized classes corresponding to each of the primitive data
types. These are called wrapper classes. They are e.g. Integer, Character, Double
etc.
TOP
[ Received from Sandesh Sadhale]
Q:
Why do we need wrapper classes?
A: It is sometimes easier to deal with primitives as objects. Moreover most of the
collection classes store objects and not primitive data types. And also the wrapper
classes provide many utility methods also. Because of these resons we need
wrapper classes. And since we create instances of these classes we can store them
in any of the collection classes and pass them around as a collection. Also we can
pass them around as method parameters where a method expects an object.
TOP
[ Received from Sandesh Sadhale]
Q:
What are checked exceptions?
A: Checked exception are those which the Java compiler forces you to catch. e.g.
IOException are checked Exceptions.
TOP
[ Received from Sandesh Sadhale]
Q:
What are runtime exceptions?
A: Runtime exceptions are those exceptions that are thrown at runtime because of
either wrong input data or because of wrong business logic etc. These are not
checked by the compiler at compile time.
TOP
[ Received from Sandesh Sadhale]
Q:
What is the difference between error and an exception?
A: An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory
error. These JVM errors and you can not repair them at runtime. While exceptions
are conditions that occur because of bad input etc. e.g. FileNotFoundException will

be thrown if the specified file does not exist. Or a NullPointerException will take
place if you try using a null reference. In most of the cases it is possible to recover
from an exception (probably by giving user a feedback for entering proper values
etc.).
TOP
[ Received from Sandesh Sadhale]
Q:
How to create custom exceptions?
A: Your class should extend class Exception, or some more specific type thereof.
TOP
[ Received from Sandesh Sadhale]
Q:
If I want an object of my class to be thrown as an exception object, what
should I do?
A: The class should extend from Exception class. Or you can extend your class from
some more precise exception type also.
TOP
[ Received from Sandesh Sadhale]
Q:
If my class already extends from some other class what should I do if I
want an instance of my class to be thrown as an exception object?
A: One can not do anytihng in this scenarion. Because Java does not allow multiple
inheritance and does not provide any exception interface as well.
TOP
[ Received from Sandesh Sadhale]
Q:
What happens to an unhandled exception?
A: One can not do anytihng in this scenarion. Because Java does not allow multiple
inheritance and does not provide any exception interface as well.
TOP
[ Received from Sandesh Sadhale]
Q:
How does an exception permeate through the code?
A: An unhandled exception moves up the method stack in search of a matching When
an exception is thrown from a code which is wrapped in a try block followed by
one or more catch blocks, a search is made for matching catch block. If a
matching type is found then that block will be invoked. If a matching type is not
found then the exception moves up the method stack and reaches the caller
method. Same procedure is repeated if the caller method is included in a try catch
block. This process continues until a catch block handling the appropriate type of
exception is found. If it does not find such a block then finally the program
terminates.
TOP
[ Received from Sandesh Sadhale]
Q:
What are the different ways to handle exceptions?
A: There
are
two
ways
to
handle
exceptions,
1. By wrapping the desired code in a try block followed by a catch block to catch
the
exceptions.
and

2. List the desired exceptions in the throws clause of the method and let the caller
of the method hadle those exceptions.
TOP
[ Received from Sandesh Sadhale]
Q:
Q: What is the basic difference between the 2 approaches to exception
handling...1> try catch block and 2> specifying the candidate exceptions
in
the
throws
clause?
When should you use which approach?
A: In the first approach as a programmer of the method, you urself are dealing with
the exception. This is fine if you are in a best position to decide should be done in
case of an exception. Whereas if it is not the responsibility of the method to deal
with it's own exceptions, then do not use this approach. In this case use the
second approach. In the second approach we are forcing the caller of the method
to catch the exceptions, that the method is likely to throw. This is often the
approach library creators use. They list the exception in the throws clause and we
must catch them. You will find the same approach throughout the java libraries we
use.
TOP
[ Received from Sandesh Sadhale]
Q:
Is it necessary that each try block must be followed by a catch block?
A: It is not necessary that each try block must be followed by a catch block. It should
be followed by either a catch block OR a finally block. And whatever exceptions
are likely to be thrown should be declared in the throws clause of the method.
TOP
[ Received from Sandesh Sadhale]
Q:
If I write return at the end of the try block, will the finally block still
execute?
A: Yes even if you write return as the last statement in the try block and no exception
occurs, the finally block will execute. The finally block will execute and then the
control return.
TOP
[ Received from Sandesh Sadhale]
Q:
If I write System.exit (0); at the end of the try block, will the finally block
still execute?
A: No in this case the finally block will not execute because when you say
System.exit (0); the control immediately goes out of the program, and thus finally
never executes.
Q:
How are Observer and Observable used?
A: Objects that subclass the Observable class maintain a list of observers. When an
Observable object is updated it invokes the update() method of each of its
observers to notify the observers that it has changed state. The Observer interface
is implemented by objects that observe Observable objects.
TOP
[Received from Venkateswara Manam]

Q:
What is synchronization and why is it important?
A: With respect to multithreading, synchronization is the capability to control
the access of multiple threads to shared resources. Without synchronization, it is
possible for one thread to modify a shared object while another thread is in the
process of using or updating that object's value. This often leads to significant
errors.
TOP
[ Received from Venkateswara Manam]
Q:
How does Java handle integer overflows and underflows?
A: It uses those low order bytes of the result that can fit into the size of the type
allowed by the operation.
TOP
[ Received from Venkateswara Manam]
Q:
Does garbage collection guarantee that a program will not run out of
memory?
A: Garbage collection does not guarantee that a program will not run out of memory.
It is possible for programs to use up memory resources faster than they are
garbage collected. It is also possible for programs to create objects that are not
subject
to
garbage
collection
.
TOP
[ Received from Venkateswara Manam]
Q:
What is the difference between preemptive scheduling and time slicing?
A: Under preemptive scheduling, the highest priority task executes until it enters the
waiting or dead states or a higher priority task comes into existence. Under time
slicing, a task executes for a predefined slice of time and then reenters the pool of
ready tasks. The scheduler then determines which task should execute next,
based on priority and other factors.
TOP
[ Received from Venkateswara Manam]
Q:
When a thread is created and started, what is its initial state?
A: A thread is in the ready state after it has been created and started.
[ Received from Venkateswara Manam]

TOP

Q:
What is the purpose of finalization?
A: The purpose of finalization is to give an unreachable object the opportunity to
perform any cleanup processing before the object is garbage collected.
TOP
[ Received from Venkateswara Manam]
Q:
What is the Locale class?
A: The Locale class is used to tailor program output to the conventions of a particular
geographic, political, or cultural region.

[ Received from Venkateswara Manam]

TOP

Q:
What is the difference between a while statement and a do statement?
A: A while statement checks at the beginning of a loop to see whether the next loop
iteration should occur. A do statement checks at the end of a loop to see whether
the next iteration of a loop should occur. The do statement will always execute the
body of a loop at least once.
TOP
[ Received from Venkateswara Manam]
Q:
What is the difference between static and non-static variables?
A: A static variable is associated with the class as a whole rather than with specific
instances of a class. Non-static variables take on unique values with each object
instance.
TOP
[ Received from Venkateswara Manam]
Q:
How are this() and super() used with constructors?
A: Othis() is used to invoke a constructor of the same class. super() is used to invoke
a superclass constructor.
TOP
[ Received from Venkateswara Manam]
Q:
What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A
thread only executes a synchronized method after it has acquired the lock for the
method's object or class. Synchronized statements are similar to synchronized
methods. A synchronized statement can only be executed after a thread has
acquired the lock for the object or class referenced in the synchronized statement.
TOP
[ Received from Venkateswara Manam]
Q:
What is daemon thread and which method is used to create the daemon
thread?
A: Daemon thread is a low priority thread which runs intermittently in the back
ground doing the garbage collection operation for the java runtime system.
setDaemon method is used to create a daemon thread.
TOP
[ Received from Shipra Kamra]
Q:
Can applets communicate with each other?
A: At this point in time applets may communicate with other applets running in the
same virtual machine. If the applets are of the same class, they can communicate
via shared static variables. If the applets are of different classes, then each will
need a reference to the same class with static variables. In any case the basic idea
is to pass the information back and forth through a static variable.
An applet can also get references to all other applets on the same page using the

getApplets() method of java.applet.AppletContext. Once you\'ve got a reference to


an applet, you can communicate with it by using its public members.
It is conceivable to have applets in different virtual machines that talk to a server
somewhere on the Internet and store any data that needs to be serialized there.
Then, when another applet needs this data, it could connect to this same server.
Implementing this is non-trivial.
TOP
[ Received from Krishna Kumar ]
Q:
A:

What are the steps in the JDBC connection?


While making a JDBC connection we go through the following steps :
Step 1 : Register the database driver by using :
Class.forName(\" driver classs for that specific database\" );
Step 2 : Now create a database connection using :
Connection con = DriverManager.getConnection(url,username,password);
Step 3: Now Create a query using :
Statement stmt = Connection.Statement(\"select * from TABLE NAME\");
Step 4 : Exceute the query :
stmt.exceuteUpdate();
[ Received from Shri Prakash Kunwar]

TOP

Q:
How does a try statement determine which catch clause should be used to
handle an exception?
A:
When an exception is thrown within the body of a try statement, the catch clauses
of the try statement are examined in the order in which they appear. The first
catch clause that is capable of handling the exceptionis executed. The remaining
catch clauses are ignored.
Q:
Can an unreachable object become reachable again?
A: An unreachable object may become reachable again. This can happen when the
object's finalize() method is invoked and the object performs an operation which
causes it to become accessible to reachable objects.
TOP
[Received from P Rajesh]
Q:
What method must be implemented by all threads?
A: All tasks must implement the run() method, whether they are a subclass of Thread

or implement the Runnable interface.


[ Received from P Rajesh]

TOP

Q:
What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A
thread only executes a synchronized method after it has acquired the lock for the
method's object or class. Synchronized statements are similar to synchronized
methods. A synchronized statement can only be executed after a thread has
acquired the lock for the object or class referenced in the synchronized statement.
TOP
[ Received from P Rajesh]
Q:
What is Externalizable?
A: Externalizable is an Interface that extends Serializable Interface. And sends data
into
Streams
in
Compressed
Format.
It
has
two
methods,
writeExternal(ObjectOuput out) and readExternal(ObjectInput in)
TOP
[ Received from Venkateswara Manam]
Q:
What modifiers are allowed for methods in an Interface?
A: Only public and abstract modifiers are allowed for methods in interfaces.
TOP
[ Received from P Rajesh]
Q:
What are some alternatives to inheritance?
A: Delegation is an alternative to inheritance. Delegation means that you include an
instance of another class as an instance variable, and forward messages to the
instance. It is often safer than inheritance because it forces you to think about
each message you forward, because the instance is of a known class, rather than
a new class, and because it doesn't force you to accept all the methods of the
super class: you can provide only the methods that really make sense. On the
other hand, it makes you write more code, and it is harder to re-use (because it is
not a subclass).
TOP
[ Received from P Rajesh]
Q:
What does it mean that a method or field is "static"?
A: Static variables and methods are instantiated only once per class. In other words
they are class variables, not instance variables. If you change the value of a static
variable in a particular object, the value of that variable changes for all instances
of that class.
Static methods can be referenced with the name of the class rather than the name
of a particular object of the class (though that works too). That's how library
methods like System.out.println() work out is a static field in the java.lang.System
class.
[ Received from P Rajesh]

TOP

Q:
What is the catch or declare rule for method declarations?
A: If a checked exception may be thrown within the body of a method, the method
must either catch the exception or declare it in its throws clause.

Java Collection Questions


Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:

What is the Collections API?


What is the List interface?
What is the Vector class?
What is an Iterator interface?
Which java.util classes and interfaces support event handling?
What is the GregorianCalendar class?
What is the Locale class?
What is the SimpleTimeZone class?
What is the Map interface?
What is the highest-level event class of the event-delegation model?
What is the Collection interface?
What is the Set interface?
What is the typical use of Hashtable?
I am trying to store an object using a key in a Hashtable. And some other
object already exists in that location, then what will happen? The existing
object will be overwritten? Or the new object will be stored elsewhere?
What is the difference between the size and capacity of a Vector?

Question:
Question: Can a vector contain heterogenous objects?
Q:
What is the Collections API?
A: The Collections API is a set of classes and interfaces that support operations on
collections of objects.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the List interface?
A: The List interface provides support for ordered collections of objects.
[ Received from SPrasanna Inamanamelluri]

TOP

Q:
What is the Vector class?
A: The Vector class provides the capability to implement a growable array of objects.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is an Iterator interface?

A: The Iterator interface is used to step through the elements of a Collection.


[ Received from Prasanna Inamanamelluri]

TOP

Q:
Which java.util classes and interfaces support event handling?
A: The EventObject class and the EventListener interface support event processing.
TOP
[ Received from Prasanna Inamanamelluri]
Q:
What is the GregorianCalendar class?
A: The GregorianCalendar provides support for traditional Western calendars
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the SimpleTimeZone class?
A: The SimpleTimeZone class provides support for a Gregorian calendar .
[ Received from Prasanna Inamanamelluri]

TOP

Q:
What is the Map interface?
A: The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys
with values.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the highest-level event class of the event-delegation model?
A: The java.util.EventObject class is the highest-level class in the event-delegation
class hierarchy.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the Collection interface?
A: The Collection interface provides support for the implementation of a
mathematical bag - an unordered collection of objects that may contain
duplicates.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the Set interface?
A: The Set interface provides methods for accessing the elements of a finite
mathematical set. Sets do not allow duplicate elements.
[ Received from Prasanna Inamanamelluri]

TOP

Q:
What is the typical use of Hashtable?
A: Whenever a program wants to store a key value pair, one can use Hashtable.
[ Received from Sandesh Sadhale]

TOP

Q:
I am trying to store an object using a key in a Hashtable. And some other
object already exists in that location, then what will happen? The existing
object will be overwritten? Or the new object will be stored elsewhere?
A: The existing object will be overwritten and thus it will be lost.
[ Received from Sandesh Sadhale]

TOP

Q:
What is the difference between the size and capacity of a Vector?
A: The size is the number of elements actually stored in the vector, while capacity is
the maximum number of elements it can store at a given instance of time.
[ Received from Sandesh Sadhale]
TOP
Q:
Can a vector contain heterogenous objects?
A: Yes a Vector can contain heterogenous objects. Because a Vector stores
everything in terms of Object.
[ Received from Sandesh Sadhale]

TOP

Q:
Can a ArrayList contain heterogenous objects?
A: Yes a ArrayList can contain heterogenous objects. Because a ArrayList stores
everything in terms of Object.
[ Received from Sandesh Sadhale]

TOP

Q:
What is an enumeration?
A: An enumeration is an interface containing methods for accessing the underlying
data structure from which the enumeration is obtained. It is a construct which
collection classes return when you request a collection of all the objects stored in
the collection. It allows sequential access to all the elements stored in the
collection.
[ Received from Sandesh Sadhale]
TOP
Q:
Considering the basic properties of Vector and ArrayList, where will you
use Vector and where will you use ArrayList?
A: The basic difference between a Vector and an ArrayList is that, vector is
synchronized while ArrayList is not. Thus whenever there is a possibility of multiple
threads accessing the same instance, one should use Vector. While if not multiple
threads are going to access the same instance then use ArrayList. Non
synchronized data structure will give better performance than the synchronized
one.
[ Received from Sandesh Sadhale]
TOP

JSP Questions
Question:What is a output comment?
Question:What is a Hidden comment?
Question:What is an Expression?
Question:What is a Declaration ?
Question:What is a Scriptlet?
Question:What are implicit objects? List them?
Question:Difference between forward and sendRedirect?
Question:What are the different scope values for the <jsp:useBean>?
Question:Explain the life-cycle methods in JSP?
Q:
What is a output comment?
A: A comment that is sent to the client in the viewable page source.The JSP engine
handles an output comment as uninterpreted HTML text, returning the comment in
the HTML output sent to the client. You can see the comment by viewing the page
source from your Web browser.
JSP
Syntax
<!-comment
[
<%=
expression
%>
]
-->
Example
<!-This
<%=
-->

is
(new

commnet
sent
to
client
java.util.Date()).toLocaleString()

Displays
in
the
page
<!-- This is a commnet sent to client on January 24, 2004 -->

1
on
%>
source:

TOP

Q:
What is a Hidden Comment?
A: A comments that documents the JSP page but is not sent to the client. The JSP
engine ignores a hidden comment, and does not process any code within hidden
comment tags. A hidden comment is not sent to the client, either in the displayed
JSP page or the HTML page source. The hidden comment is useful when you want
to hide or "comment out" part of your JSP page.
You can use any characters in the body of the comment except the closing --%>
combination. If you need to use --%> in your comment, you can escape it by
typing
--%\>.
JSP
Syntax
<%-- comment --%>
Examples
<%@
page
language="java"
%>
<html>
<head><title>A
Hidden
Comment
</title></head>
<body>
<%-- This comment will not be visible to the colent in the page source --%>
</body>

</html>
TOP

Q:
What is a Expression?
A: An expression tag contains a scripting language expression that is evaluated,
converted to a String, and inserted where the expression appears in the JSP file.
Because the value of an expression is converted to a String, you can use an
expression
within
text
in
a
JSP
file.
Like
<%=
someexpression
%>
<%=
(new
java.util.Date()).toLocaleString()
%>
You cannot use a semicolon to end an expression
TOP

Q:
What is a Declaration?
A: A declaration declares one or more variables or methods for use later in the JSP
source file.
A declaration must contain at least one complete declarative statement. You can
declare any number of variables or methods within one declaration tag, as long as
they are separated by semicolons. The declaration must be valid in the scripting
language
used
in
the
JSP
file.
<%!
<%!
int
<%! int a, b, c; %>

somedeclarations
i
=

0;

%>
%>

TOP

Q:
What is a Scriptlet?
A: A scriptlet can contain any number of language statements, variable or method
declarations, or expressions that are valid in the page scripting language.Within
scriptlet tags, you can
1.Declare variables or methods to use later in the file (see also Declaration).
2.Write expressions valid in the page scripting language (see also Expression).
3.Use any of the JSP implicit objects or any object declared with a <jsp:useBean>
tag.
You must write plain text, HTML-encoded text, or other JSP tags outside the
scriptlet.
Scriptlets are executed at request time, when the JSP engine processes the client
request. If the scriptlet produces output, the output is stored in the out object,
from which you can display it.

TOP

Q:
What are implicit objects? List them?
A: Certain objects that are available for the use in JSP documents without being
declared first. These objects are parsed by the JSP engine and inserted into the
generated servlet. The implicit objects re listed below
request
response
pageContext
session
application
out
config
page

exception

TOP

Q:
Difference between forward and sendRedirect?
A: When you invoke a forward request, the request is sent to another resource on the
server, without the client being informed that a different resource is going to
process the request. This process occurs completly with in the web container.
When a sendRedirtect method is invoked, it causes the web container to return to
the browser indicating that a new URL should be requested. Because the browser
issues a completly new request any object that are stored as request attributes
before the redirect occurs will be lost. This extra round trip a redirect is slower
than forward.
TOP

Q:
What are the different scope valiues for the <jsp:useBean>?
A: The different scope values for <jsp:useBean> are
1.
2.
3.session
4.application

page
request

TOP

Q:
Explain the life-cycle mehtods in JSP?
A:
THe generated servlet class for a JSP page implements the HttpJspPage interface
of the javax.servlet.jsp package. The HttpJspPage interface extends the JspPage
interface which inturn extends the Servlet interface of the javax.servlet package.
the generated servlet class thus implements all the methods of the these three
interfaces. The JspPage interface declares only two mehtods - jspInit() and

jspDestroy() that must be implemented by all JSP pages regardless of the clientserver protocol. However the JSP specification has provided the HttpJspPage
interfaec specifically for the JSp pages serving HTTP requests. This interface
declares
one
method
_jspService().
The jspInit()- The container calls the jspInit() to initialize te servlet instance.It is
called before any other method, and is called only once for a servlet instance.
The _jspservice()- The container calls the _jspservice() for each request, passing
it
the
request
and
the
response
objects.
The jspDestroy()- The container calls this when it decides take the instance out of
service. It is the last method called n the servlet instance.
Q:
How do I prevent the output of my JSP or Servlet pages from being
cached by the browser?
A: You will need to set the appropriate HTTP header attributes to prevent the
dynamic content output by the JSP page from being cached by the browser. Just
execute the following scriptlet at the beginning of your JSP pages to prevent them
from being cached at the browser. You need both the statements to take care of
some of the older browser versions.
<%
response.setHeader("Cache-Control","no-store");
//HTTP
1.1
response.setHeader("Pragma\","no-cache");
//HTTP
1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
[ Received from Sumit Dhamija ]

TOP

Q:
How does JSP handle run-time exceptions?
A: You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically forwarded to an error processing page. For
example:
<%@ page errorPage=\"error.jsp\" %> redirects the browser to the JSP page
error.jsp if an uncaught exception is encountered during request processing.
Within error.jsp, if you indicate that it is an error-processing page, via the
directive: <%@ page isErrorPage=\"true\" %> Throwable object describing the
exception may be accessed within the error page via the exception implicit object.
Note: You must always use a relative URL as the value for the errorPage attribute.
TOP
[ Received from Sumit Dhamija ]
Q:
How can I implement a thread-safe JSP page? What are the advantages
and Disadvantages of using it?
A: You can make your JSPs thread-safe by having them implement the
SingleThreadModel interface. This is done by adding the directive <%@ page
isThreadSafe="false" %> within your JSP page. With this, instead of a single
instance of the servlet generated for your JSP page loaded in memory, you will
have N instances of the servlet loaded and initialized, with the service method of
each instance effectively synchronized. You can typically control the number of
instances (N) that are instantiated for all servlets implementing SingleThreadModel

through the admin screen for your JSP engine. More importantly, avoid using the
tag for variables. If you do use this tag, then you should set isThreadSafe to true,
as mentioned above. Otherwise, all requests to that page will access those
variables, causing a nasty race condition. SingleThreadModel is not recommended
for normal use. There are many pitfalls, including the example above of not being
able to use <%! %>. You should try really hard to make them thread-safe the old
fashioned way: by making them thread-safe.
TOP
[ Received from Sumit Dhamija ]
Q:
How do I use a scriptlet to initialize a newly instantiated bean?
A: A jsp:useBean action may optionally have a body. If the body is specified, its
contents will be automatically invoked when the specified bean is instantiated.
Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the
newly instantiated bean, although you are not restricted to using those alone.
The following example shows the today property of the Foo bean initialized to
the current date when it is instantiated. Note that here, we make use of a JSP
expression
within
the
jsp:setProperty
action.
<jsp:useBean id="foo" class="com.Bar.Foo" >
<jsp:setProperty
name="foo"
property="today"
value="<%=java.text.DateFormat.getDateInstance().format(new java.util.Date())
%>" / >
<%-- scriptlets calling bean setter methods go here --%>
</jsp:useBean >
[ Received from Sumit Dhamija ]

TOP

Q:
How can I prevent the word "null" from appearing in my HTML input text
fields when I populate them with a resultset that has null values?
A: You could make a simple wrapper function, like
<%!
String
return
}
%>

(s

blanknull(String
==
null)

s)
\"\"

{
s;

then use it inside your JSP form, like


<input type="text" name="lastName" value="<%=blanknull(lastName)% >" >
[ Received from Sumit Dhamija ]

TOP

Q:
What's a better approach for enabling thread-safe servlets and JSPs?
SingleThreadModel Interface or Synchronization?
A: Although the SingleThreadModel technique is easy to use, and works well for low
volume sites, it does not scale well. If you anticipate your users to increase in the
future, you may be better off implementing explicit synchronization for your
shared data. The key however, is to effectively minimize the amount of code that
is synchronzied so that you take maximum advantage of multithreading.
Also, note that SingleThreadModel is pretty resource intensive from the server\'s
perspective. The most serious issue however is when the number of concurrent
requests exhaust the servlet instance pool. In that case, all the unserviced
requests are queued until something becomes free - which results in poor
performance. Since the usage is non-deterministic, it may not help much even if
you did add more memory and increased the size of the instance pool.
[ Received from Sumit Dhamija ]

TOP

Q:
How can I enable session tracking for JSP pages if the browser has
disabled cookies?
A: We know that session tracking uses cookies by default to associate a session
identifier with a unique user. If the browser does not support cookies, or if cookies
are disabled, you can still enable session tracking using URL rewriting. URL
rewriting essentially includes the session ID within the link itself as a name/value
pair. However, for this to be effective, you need to append the session ID for each
and every link that is part of your servlet response. Adding the session ID to a link
is greatly simplified by means of of a couple of methods: response.encodeURL()
associates a session ID with a given URL, and if you are using redirection,
response.encodeRedirectURL() can be used by giving the redirected URL as input.
Both encodeURL() and encodeRedirectedURL() first determine whether cookies are
supported by the browser; if so, the input URL is returned unchanged since the
session
ID
will
be
persisted
as
a
cookie.
Consider the following example, in which two JSP files, say hello1.jsp and
hello2.jsp, interact with each other. Basically, we create a new session within
hello1.jsp and place an object within this session. The user can then traverse to
hello2.jsp by clicking on the link present within the page. Within hello2.jsp, we
simply extract the object that was earlier placed in the session and display its
contents. Notice that we invoke the encodeURL() within hello1.jsp on the link used
to invoke hello2.jsp; if cookies are disabled, the session ID is automatically
appended to the URL, allowing hello2.jsp to still retrieve the session object. Try
this example first with cookies enabled. Then disable cookie support, restart the
brower, and try again. Each time you should see the maintenance of the session
across pages. Do note that to get this example to work with cookies disabled at
the browser, your JSP engine has to support URL rewriting.
hello1.jsp
<%@
page
<%
Integer
num
session.putValue("num",num);

session=\"true\"
=

new

%>
Integer(100);

String
url
%>
<a href=\'<%=url%>\'>hello2.jsp</a>

Q:

hello2.jsp
<%@
<%
Integer
out.println("Num
%>

page
i=
value

=response.encodeURL("hello2.jsp");

session="true"
in

(Integer
session

is

%>

)session.getValue("num");
"
+
i.intValue());

What is the difference b/w variable declared inside a declaration part and
variable declared in scriplet part?
A: Variable declared inside declaration part is treated as a global variable.that means
after convertion jsp file into servlet that variable will be in outside of service
method or it will be declared as instance variable.And the scope is available to
complete jsp and to complete in the converted servlet class.where as if u declare a
variable inside a scriplet that variable will be declared inside a service method and
the scope is with in the service method.
[ Received from Neelam Gangadhar]
TOP
Q:
How does JSP handle run-time exceptions?
A: You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically forwarded to an error processing page. For
example:
<%@ page errorPage=\"error.jsp\" %> redirects the browser to the JSP page
error.jsp if an uncaught exception is encountered during request processing.
Within error.jsp, if you indicate that it is an error-processing page, via the
directive: <%@ page isErrorPage=\"true\" %> Throwable object describing the
exception may be accessed within the error page via the exception implicit object.
Note: You must always use a relative URL as the value for the errorPage attribute.
TOP
[ Received from Sumit Dhamija ]
Q:
How do I use a scriptlet to initialize a newly instantiated bean?
A: A jsp:useBean action may optionally have a body. If the body is specified, its
contents will be automatically invoked when the specified bean is instantiated.
Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the
newly instantiated bean, although you are not restricted to using those alone.
The following example shows the today property of the Foo bean initialized to
the current date when it is instantiated. Note that here, we make use of a JSP
expression
within
the
jsp:setProperty
action.
<jsp:useBean id="foo" class="com.Bar.Foo" >
<jsp:setProperty
name="foo"
property="today"
value="<%=java.text.DateFormat.getDateInstance().format(new java.util.Date())

%>" / >
<%-- scriptlets calling bean setter methods go here --%>
</jsp:useBean >
[ Received from Sumit Dhamija ]

TOP

Q:

A:

Is there a way to execute a JSP from the comandline or from my own


application?
There is a little tool called JSPExecutor that allows you to do just that. The
developers
(Hendrik
Schreiber
<hs@webapp.de>
&
Peter
Rossbach
<pr@webapp.de>) aim was not to write a full blown servlet engine, but to provide
means to use JSP for generating source code or reports. Therefore most HTTPspecific features (headers, sessions, etc) are not implemented, i.e. no reponseline
or header is generated. Nevertheless you can use it to precompile JSP for your
website.

Servlet Questions
Question:Explain the life cycle methods of a Servlet.
Question:What if the static modifier is removed from the signature of the main
method?
Question:Explain the directory structure of a web application.
Question:What are the common mechanisms used for session tracking?
Question:Explain ServletContext.
Question:
What is preinitialization of a servlet?
Question:
What is the difference between Difference between doGet() and doPost()?
Question:
What is the difference between HttpServlet and GenericServlet?
Question:
What is the difference between ServletContext and ServletConfig?

Q:
Explain the life cycle methods of a Servlet.
A: The javax.servlet.Servlet interface defines the three methods known as life-cycle
method.
public
void
init(ServletConfig
config)
throws
ServletException
public void service( ServletRequest req, ServletResponse res) throws
ServletException,
IOException
public
void
destroy()
First the servlet is constructed, then initialized wih the init() method.

Any request from client are handled initially by the service() method before
delegating to the
doXxx() methods in the case of HttpServlet.
The servlet is removed from service, destroyed with the destroy() methid, then
garbaged collected and finalized.
TOP

Q:
What is the difference between the getRequestDispatcher(String path)
method
of
javax.servlet.ServletRequest
interface
and
javax.servlet.ServletContext interface?
A: The getRequestDispatcher(String path) method of javax.servlet.ServletRequest
interface accepts parameter the path to the resource to be included or forwarded
to, which can be relative to the request of the calling servlet. If the path begins
with a "/" it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of javax.servlet.ServletContext
interface cannot accepts relative paths. All path must sart with a "/" and are
interpreted as relative to curent context root.
TOP

Q:
Explain the directory structure of a web application.
A: The directory structure of a web application consists
A
private
directory
called
A
public
resource
directory which
contains
public
WEB-INF
1.
2.
3. lib directory

folder

consists

of

two

parts.
WEB-INF
resource
folder.
of

classes

web.xml
directory

TOP

Q:
What are the common mechanisms used for session tracking?
A: Cookies
SSL
URL- rewriting

sessions

TOP

Q:
Explain ServletContext.
A: ServletContext interface is a window for a servlet to view it's environment. A
servlet can use this interface to get information such as initialization parameters
for the web applicationor servlet container's version. Every web application has
one and only one ServletContext and is accessible to all active resource of that
application.
TOP

Q:
What is preinitialization of a servlet?
A: A container doesnot initialize the servlets ass soon as it starts up, it initializes a
servlet when it receives a request for that servlet first time. This is called lazy
loading. The servlet specification defines the <load-on-startup> element, which
can be specified in the deployment descriptor to make the servlet container load
and initialize the servlet as soon as it starts up. The process of loading a servlet
before any request comes in is called preloading or preinitializing a servlet.
[ Received from Amit Bhoir ] TOP
Q:
What is the difference between Difference between doGet() and
doPost()?
A: A doGet() method is limited with 2k of data to be sent, and doPost() method
doesn't have this limitation. A request string for doGet() looks like the following:
http://www.allapplabs.com/svt1?p1=v1&p2=v2&...&pN=vN
doPost() method call doesn't need a long text tail after a servlet name in a
request. All parameters are stored in a request itself, not in a request string, and
it's impossible to guess the data transmitted to a servlet only looking at a request
string.
[ Received from Amit Bhoir ] TOP
Q:
What is the difference between HttpServlet and GenericServlet?
A: A GenericServlet has a service() method aimed to handle requests. HttpServlet
extends GenericServlet and adds support for doGet(), doPost(), doHead() methods
(HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1).
Both these classes are abstract.
[ Received from Amit Bhoir ] TOP
Q:
What is the difference between ServletContext and ServletConfig?
A: ServletContext: Defines a set of methods that a servlet uses to communicate
with its servlet container, for example, to get the MIME type of a file, dispatch
requests, or write to a log file.The ServletContext object is contained within the
ServletConfig object, which the Web server provides the servlet when the servlet
is
initialized
ServletConfig: The object created after a servlet is instantiated and its default
constructor is read. It is created to pass initialization information to the servlet.

EJB Questions
Q:
What are the different kinds of enterprise beans?
A: Different kind of enterrise beans are Stateless session bean, Stateful session bean,
Entity bean, Message-driven bean...........

Q:
What is Session Bean?
A: A session bean is a non-persistent object that implements some business logic
running on the server. One way to think of a session object...........
Q:
What is Entity Bean?
A: The entity bean is used to represent data in the database. It provides an objectoriented interface to ...........
Q:
What are the methods of Entity Bean?
A: An entity bean consists of 4 groups of methods, create methods...........
Q:
What is the difference between Container-Managed Persistent (CMP)
bean and Bean-Managed Persistent(BMP) ?
A: Container-managed persistence (CMP) and bean-managed persistence (BMP).
With CMP, the container manages the persistence of the entity bean............
Q:
What are the callback methods in Entity beans?
A: Callback methods allows the container to notify the bean of events in
its life cycle. The callback methods are defined in the javax.ejb.EntityBean
interface............
Q:
What is software architecture of EJB?
A: Session and Entity EJBs consist of 4 and 5 parts respectively, a remote
interface...........
Q:
Can Entity Beans have no create() methods?
A: Yes. In some cases the data is inserted NOT using Java application,...........
Q:
What is bean managed transaction?
A: If a developer doesn't want a Container to manage transactions, it's possible to
implement all database operations manually...........
Q:
What are transaction attributes?
A: The transaction attribute specifies how the Container must manage transactions
for a method when a client invokes the method via the enterprise beans home
or...........
Q:
What are transaction isolation levels in EJB?
A: Transaction_read_uncommitted
,
Transaction_read_committed

Transaction_repeatable_read...........
Q:
How EJB Invocation happens?
A: Step 1: Retrieve Home Object reference from Naming Service via JNDI.
step
2:
Return
Home
Object
reference
to
the
client.
step 3: Create me a new EJB Object through Home Object interface.
step
4:
Create
EJB
Object
from
the
Ejb
Object
step
5:
Return
EJB
Object
reference
to
the
client.
step
6:
Invoke
business
method
using
EJB
Object
reference.
step 7: Delegate request to Bean (Enterprise Bean).
[ Received from Ramana Bhavanasi]
TOP
Q:
Is it possible to share an HttpSession between a JSP and EJB? What
happens when I change a value in the HttpSession from inside an EJB?
A: You can pass the HttpSession as parameter to an EJB method, only if all objects
in session are serializable.This has to be consider as ?passed-by-value", that
means that it?s read-only in the EJB. If anything is altered from inside the EJB, it
won?t be reflected back to the HttpSession of the Servlet Container.The ?pass-byreference? can be used between EJBs Remote Interfaces, as they are remote
references. While it IS possible to pass an HttpSession as a parameter to an EJB
object, it is considered to be ?bad practice ? in terms of object oriented design.
This is because you are creating an unnecessary coupling between back-end
objects (ejbs) and front-end objects (HttpSession). Create a higher-level of
abstraction for your ejb?s api. Rather than passing the whole, fat, HttpSession
(which carries with it a bunch of http semantics), create a class that acts as a
value object (or structure) that holds all the data you need to pass back and forth
between front-end/back-end. Consider the case where your ejb needs to support a
non-http-based client. This higher level of abstraction will be flexible enough to
support it.
TOP
[ Received from Nishit Kamdar]
Q:
The EJB container implements the EJBHome and EJBObject classes. For
every request from a unique client, does the container create a separate
instance of the generated EJBHome and EJBObject classes?
A: The EJB container maintains an instance pool. The container uses these instances
for the EJB Home reference irrespective of the client request. while refering the
EJB Object classes the container creates a separate instance for each client
request. The instance pool maintainence is up to the implementation of the
container. If the container provides one, it is available otherwise it is not
mandatory for the provider to implement it. Having said that, yes most of the
container providers implement the pooling functionality to increase the
performance of the application server. The way it is implemented is again up to the
implementer.
TOP
[ Received from Vishal Khasgiwala ]
Q:
Can the primary key in the entity bean be a Java primitive type such as
int?

A:
The primary key can't be a primitive type--use the primitive wrapper classes,
instead. For example, you can use java.lang.Integer as the primary key class, but
not int (it has to be a class, not a primitive)
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
Can you control when passivation occurs?
A: The developer, according to the specification, cannot directly control when
passivation occurs. Although for Stateful Session Beans, the container cannot
passivate an instance that is inside a transaction. So using transactions can be a a
strategy to control passivation.
The ejbPassivate() method is called during passivation, so the developer has
control over what to do during this exercise and can implement the require
optimized logic.
Some EJB containers, such as BEA WebLogic, provide the ability to tune the
container to minimize passivation calls.
Taken from the WebLogic 6.0 DTD -"The passivation-strategy can be either
"default" or "transaction". With the default setting the container will attempt to
keep a working set of beans in the cache. With the "transaction" setting, the
container will passivate the bean after every transaction (or method call for a nontransactional invocation).
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
What is the advantage of using Entity bean for database operations, over
directly using JDBC API to do database operations? When would I use one
over the other?
A: Entity Beans actually represents the data in a database. It is not that Entity Beans
replaces JDBC API. There are two types of Entity Beans Container Managed and
Bean Mananged. In Container Managed Entity Bean - Whenever the instance of
the bean is created the container automatically retrieves the data from the
DB/Persistance storage and assigns to the object variables in bean for user to
manipulate or use them. For this the developer needs to map the fields in the
database to the variables in deployment descriptor files (which varies for each
vendor).
In the Bean Managed Entity Bean - The developer has to specifically make
connection, retrive values, assign them to the objects in the ejbLoad() which will
be called by the container when it instatiates a bean object. Similarly in the
ejbStore() the container saves the object values back the the persistance storage.
ejbLoad and ejbStore are callback methods and can be only invoked by the
container. Apart from this, when you use Entity beans you dont need to worry
about database transaction handling, database connection pooling etc. which are
taken care by the ejb container. But in case of JDBC you have to explicitly do the
above features. what suresh told is exactly perfect. ofcourse, this comes under the
database transations, but i want to add this. the great thing about the entity
beans of container managed, whenever the connection is failed during the

transaction processing, the database consistancy is mantained automatically. the


container writes the data stored at persistant storage of the entity beans to the
database again to provide the database consistancy. where as in jdbc api, we,
developers has to do manually.
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
A:

What is EJB QL?


EJB QL is a Query Language provided for navigation across a network of enterprise
beans and dependent objects defined by means of container managed persistence.
EJB QL is introduced in the EJB 2.0 specification. The EJB QL query language
defines finder methods for entity beans with container managed persistenceand is
portable across containers and persistence managers. EJB QL is used for queries
of two types of finder methods: Finder methods that are defined in the home
interface of an entity bean and which return entity objects. Select methods, which
are not exposed to the client, but which are used by the Bean Provider to select
persistent values that are maintained by the Persistence Manager or to select
entity objects that are related to the entity bean on which the query is defined.
TOP
[ Received from Prasanna Inamanamelluri ]

Q:
Brief description about local interfaces?
A: EEJB was originally designed around remote invocation using the Java Remote
Method Invocation (RMI) mechanism, and later extended to support to standard
CORBA transport for these calls using RMI/IIOP. This design allowed for maximum
flexibility in developing applications without consideration for the deployment
scenario, and was a strong feature in support of a goal of component reuse in
J2EE.
Many developers are using EJBs locally -- that is, some or all of their EJB calls are
between beans in a single container.
With this feedback in mind, the EJB 2.0 expert group has created a local interface
mechanism. The local interface may be defined for a bean during development, to
allow streamlined calls to the bean if a caller is in the same container. This does
not involve the overhead involved with RMI like marshalling etc. This facility will
thus improve the performance of applications in which co-location is planned.
Local interfaces also provide the foundation for container-managed relationships
among entity beans with container-managed persistence.
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
What are the special design care that must be taken when you work with
local interfaces?

A: EIt is important to understand that the calling semantics of local interfaces are
different from those of remote interfaces. For example, remote interfaces pass
parameters using call-by-value semantics, while local interfaces use call-byreference.
This means that in order to use local interfaces safely, application developers need
to carefully consider potential deployment scenarios up front, then decide which
interfaces can be local and which remote, and finally, develop the application code
with these choices in mind.
While EJB 2.0 local interfaces are extremely useful in some situations, the longterm costs of these choices, especially when changing requirements and
component reuse are taken into account, need to be factored into the design
decision.
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
What happens if remove( ) is never invoked on a session bean?
A: In case of a stateless session bean it may not matter if we call or not as in both
cases nothing is done. The number of beans in cache is managed by the container.
In case of stateful session bean, the bean may be kept in cache till either the
session times out, in which case the bean is removed or when there is a
requirement for memory in which case the data is cached and the bean is sent to
free pool.
TOP
[ Received from Prasanna Inamanamelluri ]
Q:
What is the difference between Message Driven Beans and Stateless
Session beans?
A: In several ways, the dynamic creation and allocation of message-driven bean
instances mimics the behavior of stateless session EJB instances, which exist only
for the duration of a particular method call. However, message-driven beans are
different from stateless session EJBs (and other types of EJBs) in several
significant
ways:
Message-driven beans process multiple JMS messages asynchronously, rather than
processing a serialized sequence of method calls.
Message-driven beans have no home or remote interface, and therefore cannot be
directly accessed by internal or external clients. Clients interact with messagedriven beans only indirectly, by sending a message to a JMS Queue or Topic.
Note: Only the container directly interacts with a message-driven bean by creating
bean instances and passing JMS messages to those instances as necessary.
The Container maintains the entire lifecycle of a message-driven bean; instances
cannot be created or removed as a result of client requests or other API calls.
TOP
[ Received from Prasanna Inamanamelluri ]

Q:
A:

How can I call one EJB from inside of another EJB?


EJBs can be clients of other EJBs. It just works. Use JNDI to locate the Home
Interface of the other bean, then acquire an instance reference, and so forth.
TOP
[ Received from Prasanna Inamanamelluri ]

Q:
What is an EJB Context?
A:
EJBContext is an interface that is implemented by the container, and it is also a
part of the bean-container contract. Entity beans use a subclass of EJBContext
called EntityContext. Session beans use a subclass called SessionContext. These
EJBContext objects provide the bean class with information about its container, the
client using the bean and the bean itself. They also provide other functions. See
the API docs and the spec for more details.
TOP
[ Received from Prasanna Inamanamelluri ]
Q:

A:

The EJB container implements the EJBHome and EJBObject classes. For
every request from a unique client, does the container create a separate
instance of the generated EJBHome and EJBObject classes?
The EJB container maintains an instance pool. The container uses these instances
for the EJB Home reference irrespective of the client request. While refering the
EJB Object classes the container creates a separate instance for each client
request. The instance pool maintainence is up to the implementation of the
container. If the container provides one, it is available otherwise it is not
mandatory for the provider to implement it. Having said that, yes most of the
container providers implement the pooling functionality to increase the
performance of the application server. The way it is implemented is again up to the
implementer.

JMS Questions
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:
Question:

What is JMS?
How JMS is different from RPC?
What are the advantages of JMS?

Are you aware of any major JMS products available in the market?
What are the different types of messages available in the JMS API?
What are the different messaging paradigms JMS supports?
What is the difference between topic and queue?
What is the role of JMS in enterprise solution development?
What is the basic difference between Publish Subscribe model and P2P
model?
Question: What is the use of Message object?
Question: What is the use of BytesMessage?
Question: What is the use of StreamMessage?

Question: What is
Question: What is
What is
Question:
Question: What is

the use of TextMessage?


the use of ObjectMessage?
the use of MapMessage?
the difference between BytesMessage and StreamMessage?

Q:
What is JMS?
A: JMS is an acronym used for Java Messaging Service. It is Java's answer to creating
software using asynchronous messaging. It is one of the official specifications of
the J2EE technologies and is a key technology.
[ Received from Sandesh Sadhale]
TOP
Q:
How JMS is different from RPC?
A: In RPC the method invoker waits for the method to finish execution and return the
control back to the invoker. Thus it is completely synchronous in nature. While in
JMS the message sender just sends the message to the destination and continues
it's own processing. The sender does not wait for the receiver to respond. This is
asynchronous behavior.
[ Received from Sandesh Sadhale]
TOP
Q:
What are the advantages of JMS?
A: JMS is asynchronous in nature. Thus not all the pieces need to be up all the time
for the application to function as a whole. Even if the receiver is down the MOM
will store the messages on it's behalf and will send them once it comes back up.
Thus at least a part of application can still function as there is no blocking.
[ Received from Sandesh Sadhale]
TOP
Q:
Are you aware of any major JMS products available in the market?
A: IBM's MQ Series is one of the most popular product used as Message Oriented
Middleware. Some of the other products are SonicMQ, iBus etc. Weblogic
application server also comes with built in support for JMS messaging.
[ Received from Sandesh Sadhale]
TOP
Q:
What are the different types of messages available in the JMS API?
A: Message,
TextMessage,
BytesMessage,
StreamMessage,
ObjectMessage,
MapMessage are the different messages available in the JMS API.
TOP

Q:
What are the different messaging paradigms JMS supports?
A: Publish and Subscribe i.e. pub/suc and Point to Point i.e. p2p.
[ Received from Sandesh Sadhale]

TOP

Q:
What is the difference between topic and queue?
A: A topic is typically used for one to many messaging i.e. it supports publish
subscribe model of messaging. While queue is used for one-to-one messaging i.e.
it supports Point to Point Messaging.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the role of JMS in enterprise solution development?
A: JMS
is
typically
used
in
the
following
scenarios
1. Enterprise Application Integration: - Where a legacy application is integrated
with
a
new
application
via
messaging.
2. B2B or Business to Business: - Businesses can interact with each other via
messaging because JMS allows organizations to cooperate without tightly coupling
their
business
systems.
3. Geographically dispersed units: - JMS can ensure safe exchange of data
amongst
the
geographically
dispersed
units
of
an
organization.
4. One to many applications: - The applications that have to push data in packet
to huge number of clients in a one-to-many fashion are good candidates for the
use JMS. Typical such applications are Auction Sites, Stock Quote Services etc.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the use of Message object?
A: Message is a light weight message having only header and properties and no
payload. Thus if the received are to be notified abt an event, and no data needs to
be exchanged then using Message can be very efficient.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the basic difference between Publish Subscribe model and P2P
model?
A: Publish Subscribe model is typically used in one-to-many situation. It is unreliable
but very fast. P2P model is used in one-to-one situation. It is highly reliable.
[ Received from Sandesh Sadhale]

TOP

Q:
What is the use of BytesMessage?
A: BytesMessage contains an array of primitive bytes in it's payload. Thus it can be
used for transfer of data between two applications in their native format which
may not be compatible with other Message types. It is also useful where JMS is
used purely as a transport between two systems and the message payload is
opaque to the JMS client. Whenever you store any primitive type, it is converted
into it's byte representation and then stored in the payload. There is no boundary
line between the different data types stored. Thus you can even read a long as
short. This would result in erroneous data and hence it is advisable that the
payload be read in the same order and using the same type in which it was
created by the sender.
[ Received from Sandesh Sadhale]
TOP

Q:
What is the use of StreamMessage?
A: StreamMessage carries a stream of Java primitive types as it's payload. It contains
some conveient methods for reading the data stored in the payload. However
StreamMessage prevents reading a long value as short, something that is allwed
in case of BytesMessage. This is so because the StreamMessage also writes the
type information alonwgith the value of the primitive type and enforces a set of
strict conversion rules which actually prevents reading of one primitive type as
another.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the use of TextMessage?
A: TextMessage contains instance of java.lang.String as it's payload. Thus it is very
useful for exchanging textual data. It can also be used for exchanging complex
character data such as an XML document.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the use of ObjectMessage?
A: ObjectMessage contains a Serializable java object as it's payload. Thus it allows
exchange of Java objects between applications. This in itself mandates that both
the applications be Java applications. The consumer of the message must typecast
the object received to it's appropriate type. Thus the consumer should before hand
know the actual type of the object sent by the sender. Wrong type casting would
result in ClassCastException. Moreover the class definition of the object set in the
payload should be available on both the machine, the sender as well as the
consumer. If the class definition is not available in the consumer machine, an
attempt to type cast would result in ClassNotFoundException. Some of the MOMs
might support dynamic loading of the desired class over the network, but the JMS
specification does not mandate this behavior and would be a value added service if
provided by your vendor. And relying on any such vendor specific functionality
would hamper the portability of your application. Most of the time the class need
to be put in the classpath of both, the sender and the consumer, manually by the
developer.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the use of MapMessage?
A: A MapMessage carries name-value pair as it's payload. Thus it's payload is similar
to the java.util.Properties object of Java. The values can be Java primitives or their
wrappers.
[ Received from Sandesh Sadhale]
TOP
Q:
What is the difference between BytesMessage and StreamMessage??
A: BytesMessage stores the primitive data types by converting them to their byte
representation. Thus the message is one contiguous stream of bytes. While the
StreamMessage maintains a boundary between the different data types stored

Q:

because it also stores the type information along with the value of the primitive
being stored. BytesMessage allows data to be read using any type. Thus even if
your payload contains a long value, you can invoke a method to read a short and
it will return you something. It will not give you a semantically correct data but
the call will succeed in reading the first two bytes of data. This is strictly prohibited
in the StreamMessage. It maintains the type information of the data being stored
and enforces strict conversion rules on the data being read.

What is point-to-point messaging?


A: With point-to-point message passing the sending application/client establishes a
named message queue in the JMS broker/server and sends messages to this
queue. The receiving client registers with the broker to receive messages posted
to this queue. There is a one-to-one relationship between the sending and
receiving clients.
[ Received from Prasanna Inamanamelluri ]
TOP
Q:
Can two different JMS services talk to each other? For instance, if A and B
are two different JMS providers, can Provider A send messages directly to
Provider B? If not, then can a subscriber to Provider A act as a publisher
to Provider B?
A: The answers are no to the first question and yes to the second. The JMS
specification does not require that one JMS provider be able to send messages
directly to another provider. However, the specification does require that a JMS
client must be able to accept a message created by a different JMS provider, so a
message received by a subscriber to Provider A can then be published to Provider
B. One caveat is that the publisher to Provider B is not required to handle a
JMSReplyTo header that refers to a destination that is specific to Provider A.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is the advantage of persistent message delivery compared to
nonpersistent delivery?
A: If the JMS server experiences a failure, for example, a power outage, any
message that it is holding in primary storage potentially could be lost. With
persistent storage, the JMS server logs every message to secondary storage. (The
logging occurs on the front end, that is, as part of handling the send operation
from the message producing client.) The logged message is removed from
secondary storage only after it has been successfully delivered to all consuming
clients .
[ Received from Prasanna Inamanamelluri]
TOP
Q:
Give an example of using the publish/subscribe model.
A: JMS can be used to broadcast shutdown messages to clients connected to the
Weblogic server on a module wise basis. If an application has six modules, each
module behaves like a subscriber to a named topic on the server.
[ Received from Prasanna Inamanamelluri]
TOP

Q:
Why doesn't the JMS API provide end-to-end synchronous message
delivery and notification of delivery?
A: Some messaging systems provide synchronous delivery to destinations as a
mechanism for implementing reliable applications. Some systems provide clients
with various forms of delivery notification so that the clients can detect dropped or
ignored messages. This is not the model defined by the JMS API.
JMS API messaging provides guaranteed delivery via the once-and-only-once
delivery semantics of PERSISTENT messages. In addition, message consumers can
insure reliable processing of messages by using either CLIENT_ACKNOWLEDGE
mode or transacted sessions. This achieves reliable delivery with minimum
synchronization and is the enterprise messaging model most vendors and
developers
prefer.
The JMS API does not define a schema of systems messages (such as delivery
notifications). If an application requires acknowledgment of message receipt, it
can
define
an
application-level
acknowledgment
message.
Received from Prasanna Inamanamelluri]

TOP

Q:
What are the various message types supported by JMS?
A: Stream
Messages
?
Group
of
Java
Primitives
Map Messages ? Name Value Pairs. Name being a string& Value being a java
primitive
Text Messages ? String messages (since being widely used a separate messaging
Type
has
been
supported)
Object
Messages
?
Group
of
serialize
able
java
object
Bytes Message ? Stream of uninterrupted bytes
[ Received from Prasanna Inamanamelluri]
TOP
Q:
How is a java object message delivered to a non-java Client?
A: It is according to the specification that the message sent should be received in the
same format. A non-java client cannot receive a message in the form of java
object. The provider in between handles the conversion of the data type and the
message is transferred to the other end.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What is MDB and What is the special feature of that?
A: MDB is Message driven bean, which very much resembles the Stateless session
bean. The incoming and out going messages can be handled by the Message
driven bean. The ability to communicate asynchronously is the special feature
about the Message driven bean.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What are the types of messaging?

A: There
are
two
kinds
of
Messaging.
Synchronous Messaging: Synchronous messaging involves a client that waits for
the
server
to
respond
to
a
message.
Asynchronous Messaging: Asynchronous messaging involves a client that does not
wait for a message from the server. An event is used to trigger a message from a
server.
[ Received from Prasanna Inamanamelluri]
TOP
Q:
What are the core JMS-related objects required for each JMS-enabled
application?
A: :
Each
JMS-enabled
client
must
establish
the
following:
A connection object provided by the JMS server (the message broker)
Within a connection, one or more sessions, which provide a context for message
sending
and
receiving
Within a session, either a queue or topic object representing the destination (the
message
staging
area)
within
the
message
broker
Within a session, the appropriate sender or publisher or receiver or subscriber
object (depending on whether the client is a message producer or consumer and
uses
a
point-to-point
or
publish/subscribe
strategy,
respectively)
Within a session, a message object (to send or to receive)
Q:
What is Struts?
A: The core of the Struts framework is a flexible control layer based on standard
technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well as
various Jakarta Commons packages. Struts encourages application architectures
based on the Model 2 approach, a variation of the classic Model-View-Controller
(MVC) design paradigm.
Struts provides its own Controller component and integrates with other
technologies to provide the Model and the View. For the Model, Struts can interact
with standard data access technologies, like JDBC and EJB, as well as most any
third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the
View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as
Velocity Templates, XSLT, and other presentation systems.
The Struts framework provides the invisible underpinnings every professional web
application needs to survive. Struts helps you create an extensible development
environment for your application, based on published standards and proven design
patterns.
[ Received from Ramakrishna Potluri ]
TOP
Q:
What is Jakarta Struts Framework?
A: Jakarta Struts is open source implementation of MVC (Model-View-Controller)
pattern for the development of web based applications. Jakarta Struts is robust
architecture and can be used for the development of application of any size. Struts
framework makes it much easier to design scalable, reliable Web applications with
Java.
TOP
[ Received from Dhiraj Sharma]

Q:
What is ActionServlet?
A: The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In
the the Jakarta Struts Framework this class plays the role of controller. All the
requests to the server goes through the controller. Controller is responsible for
handling all the requests.
TOP
[ Received from Dhiraj Sharma]
Q:
How you will make available any Message Resources Definitions file to
the Struts Framework Environment?
A: T Message Resources Definitions file are simple .properties files and these files
contains the messages that can be used in the struts project. Message Resources
Definitions files can be added to the struts-config.xml file through <messageresources /> tag.
Example:
<message-resources parameter=\"MessageResources\" />.
[ Received from Dhiraj Sharma]

TOP

Q:
What is Action Class?
A: The Action Class is part of the Model and is a wrapper around the business logic.
The purpose of Action Class is to translate the HttpServletRequest to the business
logic. To use the Action, we need to Subclass and overwrite the execute() method.
In the Action Class all the database/business processing are done. It is advisable
to perform all the database related stuffs in the Action Class. The ActionServlet
(commad) passes the parameterized class to Action Form using the execute()
method. The return type of the execute method is ActionForward which is used by
the Struts Framework to forward the request to the file as per the value of the
returned ActionForward object.
TOP
[ Received from Dhiraj Sharma]
Q:
What is ActionForm?
A: An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm.
ActionForm maintains the session state for web application and the ActionForm
object is automatically populated on the server side with data entered from a form
on the client side.
TOP
[ Received from Dhiraj Sharma]
Q:
What is Struts Validator Framework?
A: Struts Framework provides the functionality to validate the form data. It can be
use to validate the data on the users browser as well as on the server side. Struts
Framework emits the java scripts and it can be used validate the form data on the
client browser. Server side validation of form can be accomplished by sub classing
your From Bean with DynaValidatorForm class.

The Validator framework was developed by David Winterfeldt as third-party addon to Struts. Now the Validator framework is a part of Jakarta Commons project
and it can be used with or without Struts. The Validator framework comes
integrated with the Struts Framework and can be used without doing any extra
settings.
[ Received from Dhiraj Sharma]

TOP

Q:
Give the Details of XML files used in Validator Framework?
A: The Validator Framework uses two XML configuration files validator-rules.xml and
validation.xml. The validator-rules.xml defines the standard validation routines,
these are reusable and used in validation.xml. to define the form specific
validations. The validation.xml defines the validations applied to a form bean.
TOP
[ Received from Dhiraj Sharma]
Q:
How you will display validation fail errors on jsp page?
A: Following tag displays all the errors:
<html:errors/>
[ Received from Dhiraj Sharma]

TOP

Q:
How you will enable front-end validation based on the xml in
validation.xml?
A: The <html:javascript> tag to allow front-end validation based on the xml in
validation.xml. For example the code: <html:javascript formName=\"logonForm\"
dynamicJavascript=\"true\" staticJavascript=\"true\" /> generates the client side
java script for the form \"logonForm\" as defined in the validation.xml file. The
<html:javascript> when added in the jsp file generates the client site validation
script.
TOP
[ Received from Dhiraj Sharma]
Q:
How to get data from the velocity page in a action class?
A: We can get the values in the action classes by using data.getParameter(\"variable
name defined in the velocity page\");
Q:
How do I prevent the output of my JSP or Servlet pages from being
cached by the browser?
A: You will need to set the appropriate HTTP header attributes to prevent the
dynamic content output by the JSP page from being cached by the browser. Just
execute the following scriptlet at the beginning of your JSP pages to prevent them
from being cached at the browser. You need both the statements to take care of
some of the older browser versions.

<%
response.setHeader("Cache-Control","no-store");
//HTTP
1.1
response.setHeader("Pragma\","no-cache");
//HTTP
1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
[ Received from Sumit Dhamija ]

TOP

Q:
How does JSP handle run-time exceptions?
A: You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically forwarded to an error processing page. For
example:
<%@ page errorPage=\"error.jsp\" %> redirects the browser to the JSP page
error.jsp if an uncaught exception is encountered during request processing.
Within error.jsp, if you indicate that it is an error-processing page, via the
directive: <%@ page isErrorPage=\"true\" %> Throwable object describing the
exception may be accessed within the error page via the exception implicit object.
Note: You must always use a relative URL as the value for the errorPage attribute.
TOP
[ Received from Sumit Dhamija ]
Q:
How can I implement a thread-safe JSP page? What are the advantages
and Disadvantages of using it?
A: You can make your JSPs thread-safe by having them implement the
SingleThreadModel interface. This is done by adding the directive <%@ page
isThreadSafe="false" %> within your JSP page. With this, instead of a single
instance of the servlet generated for your JSP page loaded in memory, you will
have N instances of the servlet loaded and initialized, with the service method of
each instance effectively synchronized. You can typically control the number of
instances (N) that are instantiated for all servlets implementing SingleThreadModel
through the admin screen for your JSP engine. More importantly, avoid using the
tag for variables. If you do use this tag, then you should set isThreadSafe to true,
as mentioned above. Otherwise, all requests to that page will access those
variables, causing a nasty race condition. SingleThreadModel is not recommended
for normal use. There are many pitfalls, including the example above of not being
able to use <%! %>. You should try really hard to make them thread-safe the old
fashioned way: by making them thread-safe .
TOP
[ Received from Sumit Dhamija ]
Q:
How do I use a scriptlet to initialize a newly instantiated bean?
A: A jsp:useBean action may optionally have a body. If the body is specified, its
contents will be automatically invoked when the specified bean is instantiated.
Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the
newly instantiated bean, although you are not restricted to using those alone.
The following example shows the today property of the Foo bean initialized to
the current date when it is instantiated. Note that here, we make use of a JSP
expression
within
the
jsp:setProperty
action.

<jsp:useBean id="foo" class="com.Bar.Foo" >


<jsp:setProperty
name="foo"
property="today"
value="<%=java.text.DateFormat.getDateInstance().format(new java.util.Date())
%>" / >
<%-- scriptlets calling bean setter methods go here --%>
</jsp:useBean >
[ Received from Sumit Dhamija ]

TOP

Q:
How can I prevent the word "null" from appearing in my HTML input text
fields when I populate them with a resultset that has null values?
A: You could make a simple wrapper function, like
<%!
String
return
}
%>

(s

blanknull(String
==
null)

s)
\"\"

{
s;

then use it inside your JSP form, like


<input type="text" name="lastName" value="<%=blanknull(lastName)% >" >
[ Received from Sumit Dhamija ]

TOP

Q:
What's a better approach for enabling thread-safe servlets and JSPs?
SingleThreadModel Interface or Synchronization?
A: Although the SingleThreadModel technique is easy to use, and works well for low
volume sites, it does not scale well. If you anticipate your users to increase in the
future, you may be better off implementing explicit synchronization for your
shared data. The key however, is to effectively minimize the amount of code that
is synchronzied so that you take maximum advantage of multithreading.
Also, note that SingleThreadModel is pretty resource intensive from the server\'s
perspective. The most serious issue however is when the number of concurrent
requests exhaust the servlet instance pool. In that case, all the unserviced
requests are queued until something becomes free - which results in poor
performance. Since the usage is non-deterministic, it may not help much even if
you did add more memory and increased the size of the instance pool.
[ Received from Sumit Dhamija ]

TOP

Q:
How can I enable session tracking for JSP pages if the browser has
disabled cookies?
A: We know that session tracking uses cookies by default to associate a session
identifier with a unique user. If the browser does not support cookies, or if cookies
are disabled, you can still enable session tracking using URL rewriting. URL
rewriting essentially includes the session ID within the link itself as a name/value
pair. However, for this to be effective, you need to append the session ID for each
and every link that is part of your servlet response. Adding the session ID to a link
is greatly simplified by means of of a couple of methods: response.encodeURL()
associates a session ID with a given URL, and if you are using redirection,
response.encodeRedirectURL() can be used by giving the redirected URL as input.
Both encodeURL() and encodeRedirectedURL() first determine whether cookies are
supported by the browser; if so, the input URL is returned unchanged since the
session
ID
will
be
persisted
as
a
cookie.
Consider the following example, in which two JSP files, say hello1.jsp and
hello2.jsp, interact with each other. Basically, we create a new session within
hello1.jsp and place an object within this session. The user can then traverse to
hello2.jsp by clicking on the link present within the page. Within hello2.jsp, we
simply extract the object that was earlier placed in the session and display its
contents. Notice that we invoke the encodeURL() within hello1.jsp on the link used
to invoke hello2.jsp; if cookies are disabled, the session ID is automatically
appended to the URL, allowing hello2.jsp to still retrieve the session object. Try
this example first with cookies enabled. Then disable cookie support, restart the
brower, and try again. Each time you should see the maintenance of the session
across pages. Do note that to get this example to work with cookies disabled at
the browser, your JSP engine has to support URL rewriting.
hello1.jsp
<%@
page
<%
Integer
num
=
session.putValue("num",num);
String
url
%>
<a href=\'<%=url%>\'>hello2.jsp</a>
hello2.jsp
<%@
<%
Integer
out.println("Num
%>

session=\"true\"

page
i=
value

new

%>
Integer(100);

=response.encodeURL("hello2.jsp");

session="true"
in

(Integer
session

is

%>

)session.getValue("num");
"
+
i.intValue());

DB Questions
Question:What is SQL?
Question:What is SELECT statement?
Question:How can you compare a part of the name rather than the entire name?
Question:

What is the INSERT statement?


Question:How do you delete a record from a database?
Question:How could I get distinct entries from a table?
Question:How to get the results of a Query sorted in any order?
Question:How can I find the total number of records in a table?
Question:What is GROUP BY?
Question:What is the difference among "dropping a table", "truncating a table" and
"deleting all records" from a table?
Question:What are the Large object types suported by Oracle?
Question:Difference between a "where" clause and a "having" clause ?
Question:What's the difference between a primary key and a unique key?
Question:What are cursors? Explain different types of cursors. What are the
disadvantages of cursors? How can you avoid cursors?
Question:What are triggers? How to invoke a trigger on demand?
Question:What is a join and explain different types of joins.
Question:What is a self join?
Q:
What is SQL?
A: SQL stands for 'Structured Query Language'.
TOP

Q:
What is SELECT statement?
A: The SELECT statement lets you select a set of values from a table in a database.
The values selected from the database table would depend on the various
conditions that are specified in the SQL query.
TOP

Q:
How can you compare a part of the name rather than the entire name?
A: SELECT
*
FROM
people
WHERE
empname
LIKE
'%ab%'
Would return a recordset with records consisting empname the sequence 'ab' in
empname .
TOP

Q:
What is the INSERT statement?
A: The INSERT statement lets you insert information into a database.

TOP

Q:
How do you delete a record from a database?
A: Use the DELETE statement to remove records or any particular column values
from a database.
TOP

Q:
How could I get distinct entries from a table?
A: The SELECT statement in conjunction with DISTINCT lets you select a set of
distinct values from a table in a database. The values selected from the database
table would of course depend on the various conditions that are specified in the
SQL
query.
Example
SELECT DISTINCT empname FROM emptable
TOP

Q:
How to get the results of a Query sorted in any order?
A: You can sort the results and return the sorted results to your program by using
ORDER BY keyword thus saving you the pain of carrying out the sorting yourself.
The
ORDER
BY
keyword
is
used
for
sorting.
SELECT empname, age, city FROM emptable ORDER BY empname
TOP

Q:
A:

How can I find the total number of records in a table?


You

could

use

the

COUNT

keyword

example

SELECT COUNT(*) FROM emp WHERE age>40


TOP

Q:
What is GROUP BY?
A: The GROUP BY keywords have been added to SQL because aggregate functions
(like SUM) return the aggregate of all column values every time they are called.
Without the GROUP BY functionality, finding the sum for each individual group of
column values was not possible.
TOP

Q:
What is the difference among "dropping a table", "truncating a table" and
"deleting all records" from a table.
A: Dropping : (Table structure + Data are deleted), Invalidates the dependent
objects ,Drops the indexes
Truncating: (Data alone deleted), Performs an automatic commit, Faster than
delete
Delete : (Data alone deleted), Doesnt perform automatic commit
TOP

Q:
What are the Large object types suported by Oracle?

A: Blob and Clob.


TOP

Q:
Difference between a "where" clause and a "having" clause.
A: Having clause is used only with group functions whereas Where is not used with.
TOP

Q:
A:

What's the difference between a primary key and a unique key?


Both primary key and unique enforce uniqueness of the column on which they are
defined. But by default primary key creates a clustered index on the column,
where are unique creates a nonclustered index by default. Another major
difference is that, primary key doesn't allow NULLs, but unique key allows one
NULL only.
TOP

Q:
What are cursors? Explain different types of cursors. What are the
disadvantages of cursors? How can you avoid cursors?
A: Cursors allow row-by-row prcessing of the resultsets.
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online
for more information.
Disadvantages of cursors: Each time you fetch a row from the cursor, it results in
a network roundtrip, where as a normal SELECT query makes only one rowundtrip,
however large the resultset is. Cursors are also costly because they require more
resources and temporary storage (results in more IO operations). Furthere, there
are restrictions on the SELECT statements that can be used with some types of
cursors.
Most of the times, set based operations can be used instead of cursors.
TOP

Q:
What are triggers? How to invoke a trigger on demand?
A: Triggers are special kind of stored procedures that get executed automatically
when an INSERT, UPDATE or DELETE operation takes place on a table.
Triggers can't be invoked on demand. They get triggered only when an associated
action (INSERT, UPDATE, DELETE) happens on the table on which they are
defined.
Triggers are generally used to implement business rules, auditing. Triggers can
also be used to extend the referential integrity checks, but wherever possible, use
constraints for this purpose, instead of triggers, as constraints are much faster.

Q:
What is a join and explain different types of joins.
A: Joins are used in queries to explain how different tables are related. Joins also let
you select data from a table depending upon data from another table.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are
further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER
JOINS.
TOP

Q:
What is a self join?
A:Self join is just like any other join, except that two instances of the same
table will be joined in the query.
Sort By

Date Added

Replies

Last Update

1. Is there any difference between


Its appearing to be a nice and useful site
Comments: 6

Showing 1-10 of 165

Next Page

Execution Engine and the JIT in java?

Last Update: November 14, 2005 By g

s mohan Answer

Added: November 13,


2005

How single threaded model works after implementation in class, basically architecture
point of view.
2.

Comments: 0

Added: November 13,


2005

Answer

if two overloaded methods are-test(Object xyz) and test(Customer cust)[Assume


Customer is a class with member name of type String].Now if we call test(null), which
method
will
be
called?
why?
3.

The method - test(Customer cust) will be called. This will happen because while resolving calls to overloaded
methods, the Java compiler incorporates a 'Most Specific' algorithm. Since the value null is assignable to both
an 'Object' reference and a 'Customer'
Added: November 13,
Comments: 1
Answer
2005

WHEN UR USING ARRAYLIST AND LIKEDLIST AND VECTOR AND HASHMAP


AND
HASHTABLE?
4.

when we want to store the objects


Comments: 1

Last Update: November 13, 2005 By veerendra nadh

Answer

Added: November 12,


2005

when programmer using the vector and arrylist? and when ur using linkedlist and
hashmap
and
hashtable?
5.

pls ans me
Comments: 1

Answer

Added: November 12,


2005

6. Can wehave run() method


directly without start() method in threads?
Start method is method of Thread which is implemented for create and run thread. Which will call run() where
you put your implementation. If you directly call run() method it is just normal method call and not a new
thread. That call will be
Comments: 1 Last Update: November 13, 2005 By Mandar Arun Added: November 11,

Joshi Answer

2005

How to use JNI in java? and what are Struts and jini?and how to apply native code in
java?
7.

Pl. explain with the e.g.


Comments: 1
8.

Last Update: November 13, 2005 By Anadi Misra

Answer

Added: November 11,


2005

why the container does not support multiple layout managers


Added: November 09,
2005

Answer

Comments: 0

9. which class is the super class for all classes in java.lang package?
Class Object is the root of the all classes. Every class has Object as a superclass. All objects including arrays,
implement the methods of this class.
Comments:

Last

Update:

November

10,

2005

By

Mandar Arun

Joshi Answer

Added: November 09,


2005

What are differences between Enumeration, ArrayList, Hashtable and Collections and
Collection?
10.

Pl. escalate ur ans.


11. How many JVM could be run on an operating system. if only one then what is the logical reason.
This is difficult question. Let me explain my understanding from RMI prosepctive. RMI says it is used
for communicating betwwen distributed JVM that is different JVM. Now consider you have 2 different
java processes on same machine but you can
Comments: 16

Last Update: November 13, 2005 By

Mandar Arun

Joshi Answer

Added: November 02,


2005

12. What is JVM Heap Size? How does it affect the performance of the Application?
The heap is the runtime data area from which memory for all class instances and arrays is allocated. The heap
may be of a fixed size or may be expanded. The heap is created on virtual machine start-up. If you have
complicated algorithms or big caching
Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer
13.

so

Added: November 01,


2005

we know that Object class is super class of every class & a class extends only one class.
how is it possible to a class to extend other than Object class?

Because java supports multilevel inheritance.


Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer

Added: November 01,


2005

14. what
is
difference
between
string
and
stringtokenizer?
A StringTokenizer is utility class used to break up string.e.g. StringTokenizer st = new StringTokenizer("Hello
World"); while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer
15. how can you load DLL files
jni using here but exactly do not known.
Comments:

Last

Update:

November

Added:
2005

October

31,

when your java class is loading first time ?


11,

2005

By

Mandar Arun

Added:
2005

October

31,

Joshi Answer
if interface & abstract class have same methods & abstract class also not contain any
implementation
for
those
methods
which
one
you
prefer
?
16.

use abstract class because we implement only requried methods of abstract class but for interface we must
implement all methods whether or requried or not
Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer
17. what
is
difference
between
arraylist is resizable where as using array it is not possible.
Comments:

Last

Update:

November

11,

2005

By

array
Mandar Arun

Joshi Answer

Added:
2005

&
Added:
2005

October

30,

arraylist?
October

30,

what is difference between java.lang .Class and java.lang.ClassLoader? What is the


hierarchy
of
ClassLoader
18.

Class 'java.lang.Class' represent classes and interfaces in a running Java application. JVM construct 'Class'
object when class in loaded. Even primitive data types have 'Class' object.
Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer

Added:
2005

19. how
can
we
use
hashset
in
collection
Hashset: It belongs to Set group of Collection. It allows null as value. It is not thread-safe.
Comments:

Last

Update:

November

11,

2005

By

Mandar Arun

Joshi Answer

Added:
2005

October

29,

interface?
October

28,

why java does not support inheritance of multiple superclasses?what is achieved by


inheritance?why
there
is
no
main
method
in
servlets/jsps?
20.

A1.Consider following exampleclass A { method XYZ(//some implementation)}class B { method XYZ(//some


implementation)}class C extends A,BNow if you say C c = new C() and C.XYZ() java don't undestand which
implementation to use.A2.Inheritance achieves structure
21. What is collection framework?what interfaces and classes support collection framework?
one can use different groups of objects in program using collection frame work.for more detail
readcollection frame work from java.util pack.
Added: October 25,
Comments: 2 Last Update: October 27, 2005 By Mamatha Answer
2005

what is difference between instance and object.?what are the all difference between
interface
and
abstract
class?
22.

Object is instance of a Class.All variables of interface are by default static, final. Interface can not have
implemented methods. All methods are by default abtract.Abstract class should have at least one abstract
method, other methods can have implementatio
Comments:

Joshi Answer

Last

Update:

November

11,

2005

By

Mandar Arun

Added:
2005

October

24,

23. what's the difference b/w Java command line arg.s & C command line arg.s?
THERE IS ONE MAJOR DIFFERENCE IN COMMANDLINE ARGUMENTS OF JAVA AND C.LET US
ASSUME THERE IS AN EXECUTBLE FILE NAMED"COPY.EXE", WHICH SOURCE CODE IS IN C AND
TAKES 2 COMMANDLINE ARGUMENTS THEN WE WILL RUN IT AS
Added: October 24,
Comments: 3 Last Update: November 13, 2005 By Paramesh.A Answer
2005

What is the difference between String and StringBuffer? Which is better to use in
project?
24.

String is immutable. If you want to update string value often (build query on condition) you should use
StringBuffer.method(){String abc = "";for(int i=0;i<100;i++){ abc = abc + "d"; // each time new string object is
formed. very
Comments: 10

Last Update: November 11, 2005 By

Mandar Arun

Joshi Answer
25. what
satya has given best answer.
Comments:

Last

is

Update:

a
November

11,

Added:
2005

green
2005

By

Mandar Arun

Joshi Answer

October

24,

thread?
Added:
2005

October

21,

what is JIT? Is it bundled with JDK? If so what is the role of interpreter(java)? plz
explain
in
detail.
26.

plz give me more detailed answer


Comments: 2

Last Update: November 08, 2005 By kiran

Added:
2005

Answer

27. When
exactly
a
static
block
is
loaded
static blocks are loaded when the jvm loads the class for the first time........
Comments: 5

Last Update: November 09, 2005 By sushi

in
Added:
2005

Answer

October

20,

Java

October

19,

28. How
we know a class is Serialized or not from a package
where and when we use abstract class and abstract methods(this question is asked by tcs).
Added: October 19,
Comments: 2 Last Update: November 04, 2005 By pulipaka Answer
2005
29. When will a static variable is loaded?is it at compile time or runtime?
: When will a static variable is loaded?is it at com...
Comments: 4 Last Update: November 08, 2005 By kotresh munavalli Added: October 19,
2005
matt Answer
30. What
is the difference between transient variable,volatile variable
volatile modifier requests the Java VM to always access the shared copy of the variable so the its most current
value is always read. If two or more threads access a member variable, AND one or more threads might
change that variable's value, AND ALL
31. what
is
daemon
threads?
Any Java thread can be a daemon thread. Daemon threads are service providers for other threads
running in the same process as the daemon thread. For example, the HotJava browser uses up to four
daemon threads named "Image Fetcher" to fetch images from
Comments:
8 Last
Update:
November
04,
2005
By
Srinivas Added: October 19,
2005
Kallumadi Answer
32.

Wat is the Repeater function...and Wat does Data Integrity means?

Comments: 0

Added:
2005

Answer

33. Canweimplement
Not Possible.

aninterface

in

JSP

Page?If

yesHow?write

October

18,

thecode?

Comments: 1

Last Update: October 22, 2005 By venki MIc

Answer

Added:
2005

October

17,

why cant we compare two objects with ==,why we should use only .equals() for
objects.
34.

we can compare two Strings with (==) when we assign some string value to the String variable,but if we create
an object to that strings and compare eachother we cant use(==) operator ,because we can compare only
values with(==) operator but as Objects
Added: October 17,
Comments: 3 Last Update: November 09, 2005 By paresh Answer
2005
35. why
pointers
are
not
used
in
java
Java is developed to make easy as compared with the C and CPP. It is overcomes ambiguity of Pointers and
internally pointers are used to make user friendly. There is no technically terms to use pinter's in java as like
native keyword. &nbs
Added: October 17,
Comments: 4 Last Update: October 25, 2005 By Devidas Sonawane Answer 2005
36. Constructor
can
not
be
inherited.Why?
Tell
me
the
reason.
Constructor can not be inherited because inheritance feature is only available for class not for methods
(constructor is nothing but method) and all methods of super class is available for sub-class.
Added: October 14,
Comments: 3 Last Update: October 21, 2005 By Devidas Sonawane Answer 2005

Please give me answer why we use Interface though it contain only blank
implementation.
37.

With the inheritance we can also achieve the polymorphism concept. And the above answer also holds good.
Added: October 13,
Comments: 3 Last Update: November 13, 2005 By venkatram reddy Answer 2005
38.

the

I studied that "Abstract class means ,it doesn't maintain the complete information about
particular
class".
Is
it
right?
Justify?

Yes. The name abstract itself explains that some this is hidden. The complete implementation may not be done
in abstract class. But some thing which you don't want to disclose can be done in an abstract class. For
example. A Car class provides an abstract
Added: October 13,
Comments: 2 Last Update: October 25, 2005 By venkatram reddy Answer
2005
39. What
the act of representing
abstractionthanksAjit
Comments: 1

is
essential

features

without

abstraction?
including

Last Update: October 20, 2005 By Ajit Chugh

background

Answer

details
Added:
2005

is

known
October

as
13,

40. what will this printint i=10000System.out.println(i*i);and explain why ?


i do't know
41. How
to
access
the
values
java
to
javascript?
<% String str = "123";%><script> function f() {
alert('<%=str%>');
}</script>
Added: October 09,
Comments: 1 Last Update: October 24, 2005 By Yogesh Kumar Answer
2005

What is the statament we need to use particularly when using type2 and type 4
drivers(
example
for
type
1
jdbc.odbc.JdbcOdbcDriver)?
42.

Question: What is the statament we need to use particularly when using type2 and type 4 drivers( example for

type 1 jdbc.odbc.JdbcOdbcDriver)?Answer:
Comments: 1

Last Update: October 24, 2005 By m.kirankumar

Answer

Added:
2005

October

06,

43. How
can
u
tell
HashTable
is
Synchronized?(IBM-chennai)
HashTable is Synchronized, at a time only one thread or process can take up the HashTable object instace
and do the modifications and other process.
Added: October 05,
Comments: 1 Last Update: October 22, 2005 By Justin Answer
2005
44. How
Any Body Tell about this
Comments: 11

to

Synchronize

Last Update: November 10, 2005 By sekhar

the
Answer

HashMap
Added:
2005

October

05,

I have been doing the java project using JBuilder 2.0 as front end and oracle 8i as backend .I can't connect to oracle using JBuilder 2.0 please say detailed code for that coding.
whether i have to import extra other than import java.sql.*; when ever i import the import
oracle.jdbc.driver.Error"cannot
access
directory
oracle/jdbc/driver".
45.

I work on Java/j2ee with weblogic server. I face some problems to run the servlet programs and in J2ee entity
bean program. So, i want to the exact procedure of execution.
Added: October 04,
Comments: 1 Last Update: November 10, 2005 By Mo. Haroon Answer
2005

write classes/methods to calculate the totallength of a set of lines given the start and end
points taking into account overlapping.E.g.Line 1 start: -1.4, end: 3.2 Line 2start: 2.9, end:
4.1etc..Total length would be:line 1 length = 4.6 line 2 length =1.2, but as line 2 overlaps
line 1 by 0.3, therefore length of set is 5.5(rather than 5.8).Please see if you can think of
good solution!
46.

Comments: 0

Answer

Added:
2005

October

03,

47. what
is
the
difference
between
tomact
and
weblogic
WEBLOGIC: is a application server.Supports many protocols.Used for enterprise applications and EJBs.
Supports N-Tier architectures.Provides more scalability.TOMCAT:is a web serversupports only HTTP / HTTPS
protocolsUsed for Dynamic / static pages
Added: October 03,
Comments: 2 Last Update: October 26, 2005 By venkatram reddy Answer
2005
48. Why java does not support multiple inheritance.why we go for interfaces
Diamond problem cant be solved through multiple inheritance thats why java does not support multiple
inheritance
Added: October 03,
Comments: 2 Last Update: November 09, 2005 By paresh mishra Answer
2005
49. How
many
JVM's
we
can
run
in
a
system?
Only one JVM's we can run any Operating System. if different Operating system then need to JVM's on that
Operating system.
Added: October 03,
Comments: 3 Last Update: October 25, 2005 By Devidas Sonawane Answer 2005
50. What is the difference between Model Data and Default Model Data
51. How many threads will be created for a java program, when it is compail & run? and what are

they?
plz give answer
Comments: 4
52. How
what is ans.

Last Update: November 08, 2005 By jegadeesh

can

Comments: 1

we

emplement

strutsframework

Answer
using

Last Update: October 26, 2005 By venkatram reddy

jsp

Answer

Added:
2005

or

October

02,

servlets.Tellme.

Added:
2005

October

01,

Like Object class is inherited by every class, means every class that you define in java
is implicitely extending one class that is Object. Similarly i want to know that which
interface is implicitely implemented by every class that we define. let me know as soon as
possible.
Thanks
53.

I dont know
Comments: 2

Last Update: November 08, 2005 By jegadeesh

Answer

Added: September 29,


2005

How i can validate the user, Is there any java api is there for that. Or i can use my one
business logic. If both are possible, Then which one is the best way for real time.
54.

Need some information


Comments: 2

Last Update: November 08, 2005 By chowdary

Added: September 29,


2005

Answer

55. how
to
compare
Stringbuffer
objects?
String objects are immutable. Well let me explain taking an example:Look at the code below along with the
comments:String test = "Java"; // Create a string object "java" and assign a reference 'test ' to it.String test2 =
test; //create another reference
Added: September 29,
Comments: 2 Last Update: October 31, 2005 By Ravi Nagar Answer
2005
56. Why
should
i
use
i dont know can any body give it me

ejb

as

Comments: 3

Last Update: October 31, 2005 By littlebuddha

57. what
give the answer

is

Comments: 2

Last Update: November 08, 2005 By Satya Dev

the

difference

between

can
Answer

do

it

in

servlet?

Added: September 29,


2005

instance,object,refference,class.
Answer

Added: September 29,


2005

58. How
many
ways
do
we
have
to
load
a
class
Class.forName(MyClass);Class myClass = new Class();Call to a method that returns a class:Class
myClass;myClass = createMyClass();
Added: September 28,
Comments: 1 Last Update: November 10, 2005 By rpisack Answer
2005
59. What
is
mutable
and
immutable
in
Strings?
Mutable string means we can append to that string.example StringBuffer object is mutable string.String is
immutable objectwhen we declre String="abc"; a string object abc with fixed length is created.We cant add
anything to it .If we do java simply creates
Added: September 27,
Comments: 1 Last Update: September 29, 2005 By sunil belurgikar Answer 2005

60.

How u can implement hashmap if u r not having in JAVA?


Answer
How
We
Can
We
write
our

Comments: 0

61.
own
exceptions?
We can write our own exception by deriving our class from Exception class and implementing the toString
method with in own way.
Added: September 27,
Comments: 2 Last Update: October 01, 2005 By S.V.Sita Kiran Answer
2005

what is the difference between putting a class as abstract or if any of method in class is
declared as abstract diference of these two while extending these two types of classes
62.

A class is declared abstract for extended clarity. If any method in the class is declared abstract then the class
has to be declared abstract and the method has to be implemented in the following derived class.
Added: September 27,
Comments: 1 Last Update: October 01, 2005 By S.V.Sita Kiran Answer
2005
63.

how do you configure session bean for bean-managed transactions?

Comments: 0

Added: September 26,


2005

Answer

I need some more information about interface. For Example there is no any
functionality inside the method which is declared in any interface. Then why i want to
implement that interface to my class. 2. Statement is an interface. When i say
stmt.executeQuery(). I am getting the records in my ResultSet. How it is possible?.. since
there is no functionality insid the methods which is declared in Statement
64.

An idea
Comments: 3

Last Update: October 03, 2005 By sangeeta

Answer

Added: September 26,


2005

What is the difference between Enumeration and Iterator?. When i can use Enumeration
and when i can use iterator?. Can any one tell me the situation that only Enumeration could
able
to
solve
that
problem
and
vice
versa.
65.

In Enumeration we cant modify the elements. where as in iterator we can modify the elements
Added: September 26,
Comments: 3 Last Update: October 03, 2005 By sangeeta Answer
2005

what is the purpose of interface? And tell the difference between the class and
interface?
66.

Java dose not support multiple inheritance.To provide this functionality interface is there in java.Interface are
design to support dynamic method resolution at run time.The main difference between class and interface is
we can create object of a
Comments:
5 Last
Update:
October
25,
2005
By
anshuman Added: September 26,
2005
chhotaray Answer
67. How
can u move/drag a component placed in Swing Container?
Thirumalai's Answer : Using dnd package. ( I will place a sample code if anybody is intrested )
Added: September 23,
Comments: 0
Answer
2005
68. How
can u move/drag a component placed in Swing Container?
Thirumalai's Answer : Using dnd package. ( I will place a sample code if anybody is intrested )
Added: September 23,
Comments: 1 Last Update: October 29, 2005 By kuriakose Answer
2005

I want to create two instances of a class ,But when trying for creating third instance it
should not allow me to create . what i have to do for making this?
69.

by keepineg count of number of objectsfor examplepublic class ThreeObject{ private ThreeObject() { // no code
req'd } public static ThreeObject getThreeObject() { int count; if (ref == null) count = 0;
Comments:

Last

Update:

September

30,

2005

Naveen

By

Jayaram Answer

Added: September 21,


2005

How can I swap two variables without using a third variable?Can u plz tell me the logic
behind
it..?
70.

U can use out following Options.Option 1) a=a*b; b=a/b; a=a/b;Option 2) a=a/b; b=a*b; a=b*a;Option 3) a=a-b;
b=a+b; a=a+b;Option 4) a=a+b; b=a-b; a=a-b;
71. what
is
the
interface
of
thread?
Thread can be used in two ways 1.By implementing Runnable interface 2.By Extends Thread class
Added: September 20,
Comments: 1 Last Update: October 02, 2005 By selvam_vivek Answer
2005
72. Difference
between
Applets do not sneak into the host machine
Comments: 2

"APPLET"

Last Update: October 23, 2005 By Narinder Kaur

73. How
to
use
C++
C++ code can be used in java by declaring it as native
Comments:

and

Last

Update:

September

30,

Added: September 19,


2005

Answer

code

in

2005

"APPLICATION"

By

Java
Naveen

Jayaram Answer

Program?

Added: September 19,


2005

74. What are interfaces? or How to support multiple inheritance in Java?


An interface is a specification that exists between software components that specifies a selected means of
interaction, by means of properties of other software modules, which abstract and encapsulate their data. Java
does not support multiple inheritance
Added: September 19,
Comments: 1 Last Update: September 30, 2005 By pradeepthi Answer
2005
75. Why
Java
is
not
100%
pure
object
oriented
language?
Purely object oriented language is one which deals only with the objects. e.g. SmallTalk is the only pure object
oriented language.As java also deals with datatypes as int,float etc. which are not objects of any class,it is not
purely object oriented
Added: September 19,
Comments: 3 Last Update: October 18, 2005 By Milind Answer
2005
76. Explain
Garbage
collection
mechanism
in
Java
collecting the objects taht are no longer used. java uses System.gc() method or Runtime.gc() method here
Added: September 19,
Comments: 1 Last Update: September 30, 2005 By kuriakose Answer
2005
77. Can
I
u can thru batch process
Comments: 2

create

final

Last Update: November 07, 2005 By sandeep

executable
Answer

from

Java?

Added: September 19,


2005

78. What
is
the
meaning
of
"final"
keyword?
Final keyword is used for define constant variables and method and no body can change that variable and

method within program.


Comments: 2

Last Update: October 19, 2005 By Devidas Sonawane

Added: September 19,

Answer 2005

79. Does
Java
have
No, java remove goto keyword of C and C++. instead it has Label and break keyword.
Comments: 2

Last Update: October 19, 2005 By Devidas Sonawane

"goto"?
Added: September 19,

Answer 2005

80. What
gives java it's "write once and run anywhere"
nature?
If JVM is present then it converts .java code into .class(bytecodes) hence platform independent. But not
garbage collection and thread technology is platform independent.
81. What
is
BYTE
Code?
bytecode is nothin but machine level langauge i.e hardware can understand it.
Added: September 19,
Comments: 2 Last Update: October 19, 2005 By Devidas Sonawane Answer 2005
82. Disadvantages
of
Java
Java language runs on a virtual machine, it runs somewhat slowly compared to other programs. It is difficult to
write a perfect program, especially if it is as big as a virtual machine
Added: September 19,
Comments: 1 Last Update: September 30, 2005 By kuriakose Answer
2005
83. Difference:
AWT,
Swing
AWT is the AbstractWindowToolkit.AWT is the heavy weight component,why Because It hides the peers
component to the user.in AWT 2 instances are created,it hides to user.where as swings are the light weight
component.it wont create peers component.
Comments:
3 Last
Update:
November
03,
2005
By
Rajesh Added: September 19,
2005
Sakhamuri Answer
84. Difference:
Java
Beans,
Servlets
java bean is a reusable component,where as the servlet is the java program which extends the server
capability
Added: September 19,
Comments: 1 Last Update: September 29, 2005 By sarat Answer
2005
85. Explain
working
of
Java
Virtual
Machine
(JVM)
JVM first converts .java file into .class file by using Compiler (.class is nothig but bytecode file.) and Interpretor
reads bytecodes that runtime is faster.
Added: September 19,
Comments: 2 Last Update: October 19, 2005 By Devidas Sonawane Answer 2005
86. Explain
Java
security
model
In java, we have Sand box Security Model. Some Features Structured Memory Access(No Pointer
Arithematics) Type-safe reference casting Automatic garbage collection Array bound Checking
Added: September 19,
Comments: 1 Last Update: October 18, 2005 By pawan powar Answer
2005
87. Difference

Java,
C++
for ur answer refer to text books,my question here, are session thread safe??, also execute method of the
action class is thread safe??, i mean can multiple request process with in the execute method,.? pls email me
to arun_hyd@msn.com
Added: September 19,
Comments: 1 Last Update: October 03, 2005 By arun Answer
2005

88. Meaning
Abstract
classes,
abstract
methods
Abstract Class:- it has abstract methods and non-abstract methods. Abstract Methods:- this methods has no
body. these final and variables of these methods are static, final and protected.
Added: September 19,
Comments: 2 Last Update: October 19, 2005 By Devidas Sonawane Answer 2005
89. Why
ArrayList
is
faster
than
Vector?
Syncronisation Mechanism is more important in Vector class and b'caz of that speed of Vector reduces and
Arraylist is not Syncronized and hence faster.
Added: September 19,
Comments: 2 Last Update: October 21, 2005 By Devidas Sonawane Answer 2005
90. Whether private,protected method can be overloaded,overrided or not?Tell me reason?
We can use access specifier's and we can overload the methods also. but we can't override methods( by
changing only access specifier is just like a override.)
91. Whether
a
Class,Method
can
be
garbage
collected
or
not?How?
Class is a programme means set of instructions and method is part of that class whichever is available
in. That's why classes and methods are not garbage collected. but it's instance is garbage collected.
Added: September 19,
Comments: 2 Last Update: October 25, 2005 By Devidas Sonawane Answer 2005
92. explain
the
importance
static is one per class instead of one per object
Comments: 5

of
Answer

Last Update: November 07, 2005 By sandeep

"static"keyword
Added: September 18,
2005

93. IBM
Questions
in
Bangalore
br />1.what is oracle.2.what is major differenece oracle8i and oracle9i.4.tell me some thing ur self.5.please tell
me about oops.6.what is single inheritance.7.what is multiple inheritance.8.can java support multiple
inheritance.9.what is interface.10.what
Added: September 18,
Comments: 1 Last Update: September 29, 2005 By Padmaja Answer
2005

Why java does not support Multiple Inheritance?Why java is not pure Object
Oriented?
94.

coz different classes may have different varible with same name that may be be contadicted and can cause
confusions resulting in errors
Comments:
1 Last
Update:
October
02,
2005
By
pazhani Added: September 18,
2005
subramaniam Answer
95. why
comments

java

does

not

support

Multiple

Comments: 3

Last Update: September 30, 2005 By kuriakose

Answer

Inheritance?
Added: September 18,
2005

how hashtable is synchronized?why hashmap is not synchronized?Can we make


hashmap
synchronized?
96.

hashtable is a legacy class.every legacy class provides shnchroniztion.we can make hashmap sychornized but
it call extra method.hashmap is not synchorinized but it part of collections and it enter null values.
Comments: 1

Last Update: September 18, 2005 By

Netha Answer
97.

Rajendra kumar

Added: September 18,


2005

What is the difference between an object and an instance? And give me a real time

example

to

differentiate

these

two?

An Object May not have a class defination eg int a[] where a is an arrayAn Instance Should have a class
definationeg MyClass my=new MyClass();my is an instance
Added: September 16,
Comments: 2 Last Update: October 26, 2005 By S.Naveen Kumar Answer 2005
98. What
is
the
basic
difference
between
Java
and
.Net
Java is platform independent but it uses an respective jvms for each platform .Net is also platform
independent ie., it works on more than one os but the thing is that those platforms alll belong to windows.The
thing that microsoft havent created
Comments:
2 Last
Update:
October
02,
2005
By
pazhani Added: September 16,
2005
subramaniam Answer
99. Is
java a fully object oriented programming or not? if not why?
Java is not Fully Object Oriented langauge b'caz of it has Primitive Datatypes like float, int, char etc.
Added: September 16,
Comments: 3 Last Update: October 21, 2005 By Devidas Sonawane Answer 2005

what do you meant by private constructor? why somebody declare only private
constructor.
100.

u can have a single instance of the class at a time. to implement singleton design pattern, u can declare a
constructor private.
101. Give
example
of
:
High
severity
&
Low
priority
high severity means a matching high priority, take the example of a bugzilla with a high severity and a
low priority. For example, if the defect is a problem that blocks use of a enhancement, but that
enhancement is a corner case that has few (if any)
Added: September 16,
Comments: 1 Last Update: September 30, 2005 By kuriakose Answer
2005

It is a saying that static methods in JAVA programs should be minimised. What is the
reason for this? any problems arise or there is any performance measures to be looked into
it.
102.

Static Method shld be minimised in Java Programm.For Ex . if i am m accessing any method and request
modified the object then when other request comes it wll met to modfied Object.So we shld minimise the Static
method in Java program as Original
Added: September 16,
Comments: 1 Last Update: September 26, 2005 By Pankaj Answer
2005

how do i upload a file from client side to server side using servlet and jsp this will
happen
when
I
click
upload
button
on
web-page?
103.

<input type=file name=f>


Comments: 1

Last Update: September 18, 2005 By

Netha Answer
104.

for

Rajendra kumar

Added: September 16,


2005

What is the Difference between Design Pattern and Architecture? Can any one answer
this
plz..

Design Pattern means how u r approaching the problem.Architecture means how the data is flowing in your
application
Added: September 15,
Comments: 2 Last Update: October 26, 2005 By Devidas Sonawane Answer 2005
105.

When we are sending the serialized array object thro the network, what is being passed
is
the
value
or
the
reference
?

Java has only pass by value associated with it. Even when an Object is passed the value of Object reference
in the Stack is passed(not the actual Object in Heap) But since the value passed in is a reference to an Object
any modification to the data in
Added: September 15,
Comments: 4 Last Update: October 21, 2005 By Dileep Answer
2005
106.

write program for single objects returns two instances?


Added: September 14,
2005

Answer

Comments: 0

107. 1)whether we can set the time implicitly for the garbage collection?
No you cannot start garbage collection by your own.By executing System.gc() you just b sure that GC will b
run, but when cannot be told.
Added: September 14,
Comments: 3 Last Update: September 19, 2005 By yashpal Answer
2005
108. 1)what are the other ways to create an object otherthan creating as new object?
to create object without using new keyword isclassname obj=(cast class)Class.forName("class
name").newInstance();Anshuamn/ orissa / ndia
Comments: 3 Last Update: November 02, 2005 By anshuman Added: September 14,
2005
chhotaray Answer
109. 1)what are the other ways to create an object otherthan creating as new object?
Following ways we can create object in the other way :-ActionListener listener= new ActionHandlerClaas();
RequestDespatcher rd= request.getRequestDespatcher("file_name"); rd.forward(request, response);
Added: September 14,
Comments: 3 Last Update: October 27, 2005 By Devidas Sonawane Answer 2005
110. 1)
write
give me answer
111. 1)
write
give me answer
Comments: 5

program

that

singleton

objects

returns

two

instances?

program

that

singleton

objects

returns

two

instances?

Last Update: November 07, 2005 By Jagdeep Grewal

Answer

Added: September 14,


2005

112. why
multiple inheritance using classes is disadvantage in java
Like C++ we can't inherite classes in java b'coz variables and methods ambiguity, but by using interface we
can overcome that kind of problems easily and safely.
Added: September 12,
Comments: 2 Last Update: October 27, 2005 By Devidas Sonawane Answer 2005
113. how can we take various inputs from user as int,char,string,float etc ?
By using BufferedReader we access parameter as String and by type-casting into it into
(Integer.parseInt(variable_name)) int, float, char, double, long etc. U don't get parameter as primitive type use
Wrapper classes
Added: September 12,
Comments: 3 Last Update: October 27, 2005 By Devidas Sonawane Answer 2005
114.
How
would
you
keep
track
of
a
session
In servlets, session can be tracked using a) URL rewriting b) Hiddin FormField c) cookies and d) HttpSession
API In EJB to maintain session go for stateful session beans.
Added: September 09,
Comments: 2 Last Update: September 09, 2005 By ramesh Answer
2005
115.

How

does

serialization

work

Serialization is the process of writing down the state of an object to a persistance storage media and most
frequently it will be used in distributed systems to transfer object to remote jvm.At this is time the object state is
serialized and sent to the
Added: September 09,
Comments: 8 Last Update: October 14, 2005 By ram Answer
2005
116.
How
are
memory
leaks
possible
in
Java
Memory leaks possible in the following ways :1) When more than one threads present and no Synchronization
2) When java executes a native codes. 3) When API objects are not closed like resultSet.close
Comments:
16 Last
Update:
October
29,
2005
By
Devidas Added: September 09,
2005
Sonawane Answer
117.
What
would
happen
if
you
say
this
=
null
Left hand side of = must be a variable and not a keywords and this- is a keywords that's compile-time error.
Comments:
12 Last
Update:
October
25,
2005
By
Devidas Added: September 08,
2005
Sonawane Answer
118.
What
are
the
differences
Vector is synchronized, but ArrayList is not.
Comments: 37

between

Last Update: October 19, 2005 By seby jose

ArrayList

Answer

and

Vector

Added: September 07,


2005

119. What
is
MVC
architecture
MVC is a Model, View and Controller. Model is to store contents, View is a to show contents and Controller to
controll user inputs.
Comments:
24 Last
Update:
October
25,
2005
By
Devidas Added: September 07,
2005
Sonawane Answer
120. How an Hashtable can change the iterator? Can a HashMap change the iterator?
Hashtable will change the iterator by using Enumerator interface.Yes,we can iterate a hashmap using the
entrySet() method.
121. JVM is platform independent/dependent?why? 2) which one is faster in execution Array List or
Array?
why?
JVM is Platform dependent b'coz if JVM is not loaded in the platform then we can't run program. For
every platform need to upload JVM. ArrayList is faster than Array b'coz ArraList is not Synchronized
and they directly take parameter, less complcated
Added: September 05,
Comments: 3 Last Update: October 28, 2005 By Devidas Sonawane Answer 2005
122.
What
design
patterns
have
you
used
satyanarayana.k Wrote: hi all there are basically various patters used based on the stituations we are faced.
we have used the following as for the current project. patters like session facade when u want to interact with
entity beans
Comments: 14 Last Update: October 17, 2005 By sanjeev kumar Added: September 04,
2005
sharma Answer
123.
What
Heap is the memory area in Java.
Comments: 5

is

Last Update: September 13, 2005 By Arnab

heap
Answer

in

Java

Added: September 03,


2005

124.
Is
there
a
separate
stack
for
each
thread
in
Java
Yes. Every thread mentains its own separate stack, called Runtime Stack. Elements of the stack are the
method invocations, called activation record or stack frame. The activation record contains pertinent

information about a method like local variable


Comments: 6

Last Update: September 11, 2005 By Yash Garg

Answer

Added: September 02,


2005

125.
Would
you
like
to
derive
data
from
a
base
class
The intention behind this question is not clear here. Can u elaborate the question???????????
Added: September 02,
Comments: 2 Last Update: September 02, 2005 By Pavan Answer
2005
126.
What
is
data
encapsulation?
What
does
it
buy
you
Encapsulation:- it is a mechanism to binds data and bytecodes and b'coz of that data is protected and
becomes secure.
Added: September 02,
Comments: 7 Last Update: October 28, 2005 By Devidas Sonawane Answer 2005
127.
How
can
you
do
multiple
inheritance
in
Java
hi Devidas In Java we can use inheritance by using extends keyword. but by using implements we can
inheritance more classes and this less complicated
Added: September 02,
Comments: 7 Last Update: October 03, 2005 By Devidas Sonawane Answer 2005
128.
What
are
the
differences
between
C++
and
Java
C++ has templates but Java doesn't;C++ can pass by value(default) or by reference whereas Java can only
pass by reference (well, except primitives);C++ supports multiple inheritance but Java doesn't (although
multiple interfaces);C++ requires memory management
Added: September 02,
Comments: 9 Last Update: October 12, 2005 By Kang Wang Answer
2005
129.
Differences
between
HashList
and
HashMap,
Set
and
List
HashList is a data structure storing objects in a hash table and a list.it is a combination of hashmap and doubly
linked list. acess will be faster. HashMap is hash table implementation of map interface it is same as
HashTable except that it is unsynchronized
Added: September 01,
Comments: 4 Last Update: September 29, 2005 By kuriakose Answer
2005
130.
Explain
the
keywords
native,
transient,
volatile,
finally
native:when you want to get functionality from particular language like c/c++ native is usedTransient : it is state
of which value doesnt persist volatile : is an indication to the compiler that the value may be changed by the
program some whereFinally
131.
How
does
garbage
collection
work
When Java was originally developed, the JDK shipped with a mark-and-sweep garbage collector. A
mark-and-sweep garbage collector proceeds in two phases: Mark: identifies garbage objects Sweep:
reclaims the memory for the garbage objectsGarbage objects
Added: September 01,
Comments: 8 Last Update: October 03, 2005 By Ravi Shankar R Answer 2005
132.
Explain
Servlet
and
JSP
life
cycle
First Servlet is loaded means thread created and initialised by using init() method and it communicates with
client through service() method and unloaded servlet and call destroy() method. JSP is first converted into
servlet by using
Comments:
9 Last
Update:
November
08,
2005
By
Devidas Added: September 01,
2005
Sonawane Answer
133.
What
are
STRUTS
is a popular framework that provides support for each part of the MVC design pattern that allows you to plug in

your business logic without worrying about low-level, servlet related plumbing. Most of the struts application
use a JavaSeverPage backed
Added: September 01,
Comments: 6 Last Update: October 04, 2005 By vishnu Answer
2005
134.
What
are
the
differences
between
EJB
the ejb is interprocess component and javabeans are intraprocess component
Comments: 14

Last Update: October 08, 2005 By avinash

Answer

and

Java

beans

Added: September 01,


2005

135.
How
would
you
declare
a
SingleThreaded
servlet
One can also use synchronized classes to ensure only one instance of class is running.
Added: September 01,
Comments: 6 Last Update: October 14, 2005 By seshu Answer
2005
136.
Is
it
advisable
to
depend
on
finalize
for
all
cleanups
I dont think we should rely on finalize to clean up the resources, i like the pattern followed by .NET framework
classes, they implement a disposable interface, which contains a single method dispose, which can be called
from other objects, so as soon
Added: August 31,
Comments: 2 Last Update: August 31, 2005 By shuaib Answer
2005
137.
What
are
the
differences
between
AWT
and
Swing
Awt is heavy weight component and swing is light weight components, look and fill feature and also platform
independance.
Comments:
14 Last
Update:
October
21,
2005
By
Devidas Added: August 29,
2005
Sonawane Answer
138.
What
is
phantom
Phantom memory is false memory.Memory that does not exist in reality.
Comments: 3

Last Update: October 05, 2005 By simi

Answer

memory
Added:
2005

August

27,

139.
What
do
you
like
most
with
Ant
Ant is similar to Makefile utility in linux,Ant is extented with particularlyjava classes,product ofApache.Inshort
can be considered as a build tool helps in managing and building projects.Ant particularly works with Xmls it
searches for build.xml which
Added: August 23,
Comments: 6 Last Update: September 20, 2005 By ruchika sharma Answer 2005
140.
How
all
can
you
instantiate
final
members
We can't instantiates final member.
141.
Can
a
method
be
static
and
synchronized
a method be static and synchronized . here the lock is acquired on the class it self instead of
synchronized block(entire class will be under monitor)
Added: August 16,
Comments: 10 Last Update: October 14, 2005 By varun paramala Answer 2005
142.
How would you pass a java integer by reference to another function
In Java,Primitive Types are passed by valueObjects are passed by referenceNote: No reference will be passed
incase of Remote access. Same object can be referenced with in the JVM only.
Added: August 16,
Comments: 6 Last Update: October 17, 2005 By Ravi Kumar Answer
2005
143.

How

is

serialization

implemented

in

Java

serialization is process of writing a state into byte streamex:import java.io.serialize;....//FileOutputStream f=new


FileOutputStream("rajendra.ser");ObjectOutputStream
o=new
ObjectOutpuptStream(f);o.writeObject(f);o.fush();
Comments: 5

Last Update: September 18, 2005 By

Rajendra kumar

Netha Answer

Added:
2005

August

12,

If there are 2 different versions of object streams on disk and only one object
definition, how will the JVM reject the wrong one? Can you fool the JVM
144.

No we cannot fool the JVM It willr eject the wrong one by checking class id and definitions
Added:
Comments: 1 Last Update: August 11, 2005 By sudheer Answer
2005

August

11,

can we declare multiple main() methods in multiple classes.ie can we have each main
method
in
its
class
in
our
program?
145.

Yaa u can declare multiple main methods in different classes, this wont through any error while complition , but
it through u runtime exception stating that no main method found.So there should be only one main method in
a program
Added: August 04,
Comments: 3 Last Update: October 13, 2005 By suresh Answer
2005
146.
In
Java,
how
are
objects
/
values
passed
around
In java the Objects are passed by reference But internally it is pass by value. primitive data is directly pass by
value
Added: August 04,
Comments: 2 Last Update: August 04, 2005 By Srinvasa Reddy Answer
2005

Will there be a performance penalty if you make a method synchronized? If so, can
you
make
any
design
changes
to
improve
the
performance
147.

Performance does take a hit when using synchronization. I think the way to reduce this hit is to synchronize
only a block of code that will be accessed by threads and not synchronize the entire method.
Comments: 2

Last Update: July 24, 2005 By Faisal Ghauri

Answer

Added: July 25, 2005

148.
What is the primary advantage of XML driven Java Beans
Primary Advantages is, we don't need to add code in Java Class(attribute, Mutator Method[get/set]), Sipmply
we can add new attributes by modifying XML files. Eg . ActionForm and DynaActionForm in Struts FrameWork.
Added: July 22, 2005
Comments: 1 Last Update: July 22, 2005 By K Rajesh Achary Answer
149.
What
is
reflection
API?
How
are
they
implemented
Reflection is the process of introspecting the features and state of a class at runtime and dynamically
manipluate at run time.This is supported using Reflection API with built-in classes like
Class,Method,Fields,Constructors,etc.,
Added: July 21, 2005
Comments: 3 Last Update: July 21, 2005 By Hari Answer
150.
What
is
the
sweep
and
paint
algorithm
The painting algorithm takes as input a source image and a list of brush sizes. sweep algo is that it computes
the arrangement of n lines in the plane ... a correct algorithm,
151.
What
is
EJB
Hi, Enterprise Java bean is a server side component. it contains business logic and no system level
programming and services like transactions,threading,persistence and security as EJB server provide
all these for EJB component. EJB component
Comments:
2 Last
Update:
July
07,
2005
By
Madhuroopa
Added: July 07, 2005
Soundararajan Answer

152.
What are the disadvantages of reference counting in garbage collection
An advantage of this scheme is that it can run in small chunks of time closely interwoven with the execution of
the program. This characteristic makes it particularly suitable for real-time environments where the program
can't be interrupted for very
Comments: 1

Last Update: July 01, 2005 By Arundathi

Answer

Added: July 01, 2005

153.
What
are
the
differences
between
JIT
and
HotSpot
The Hotspot VM is a collection of techniques, the most significant of which is called "adaptive optimization. The
original JVMs interpreted bytecodes one at a time. Second-generation JVMs added a JIT compiler, which
compiles each method to native
Comments: 1

Last Update: July 01, 2005 By Arundathi

Answer

Added: July 01, 2005

154. What are the different kinds of exceptions? How do you catch a Runtime exception
CHECKED EXCEPTION: WHICH R KNOWN AT THE COMPILE TIME.EG PASSING OF WRONG NO OF
ARGUMENTS.UNCHECKED EXCEPTION:WHICH RC KNOWN AT THE RUN TIME EXCEPTION.EG
NUMBER DIVIDE BY 0.
Comments: 3

Last Update: September 11, 2005 By ROHIT

Answer

Added: July 01, 2005

What does a static inner class mean? How is it different from any other static
member
155.

A static inner class behaves like any ``outer'' class. It may contain methods and fields. It is not necessarily the
case that an instance of the outer class exists even when we have created an instance of the inner class.
Similarly, instantiating
Comments: 1

Last Update: July 01, 2005 By Arundathi

Answer

Added: July 01, 2005

156.
Does
java
do
reference
counting
It is more likely that the JVMs you encounter in the real world will use a tracing algorithm in their garbagecollected heaps
Added: July 01, 2005
Comments: 1 Last Update: July 01, 2005 By Arundathi Answer
157.
How
all
can
you
free
memory
we can use system.gc() or runtime.gc() method to garbage collect but note one point that its not sure that it will
garbage collect the object Better assign Null to unused objects
Comments: 3

Last Update: September 19, 2005 By satheesh

Answer

Added: July 01, 2005

158. When you use a struts framework, where would you place your business logic
We know how servlets and JSP's applications will be . They are all Model1 arcitectures. where we cant get the
MVC (M2c) model architecture .So, we use this structs framework. And in this we can write the Business logic
in Action class which is also called
Comments: 2

Last Update: September 12, 2005 By D.S.Reddy

Answer

Added: June 29, 2005

What is a memory footprint? How can you specify the lower and upper limits of the
RAM used by the JVM? What happens when the JVM needs more memory
159.

Memory footprint : is the amount of memory a particular application is using.The JVM keeps a check on this by
its sandbox mechanism. The sandbax always has the correct knowledge of the amount of space a particular
program is using. Many time in real world
Comments: 2

Last Update: October 17, 2005 By suken

Answer

Added: June 26, 2005

When you have an object passed to a method and when the object is reassigned to a
different
one,
then
is
the
original
reference
lost
160.

In Java, it is ALWAYS pass by VALUE. Confusion occurs because all OBJECT variables in Java are references
to objects. When we call a method in Java, the object reference is PASSED BY VALUE to the method (this

means that a variable for the method's argument


161.
Do
primitive
types
have
a
class
representation
Primitive data type has a wrapper class to present. Like for int - Integer for byte Byte, for long Long
etc ...
Added: June 26, 2005
Comments: 1 Last Update: June 26, 2005 By Ashutosh Gupta Answer
162.
How
do
you
declare
constant
values
in
java
A variable can be made constant only with the help of a final keyword. If you want to make it to be accessible
from other classes then you need static.
Comments: 3

Answer

Last Update: October 29, 2005 By Baswanth

Added: June 23, 2005

163.
How
would
you
implement
a
thread
pool
public class ThreadPool extends java.lang.Object implements ThreadPoolInt This class is an generic
implementation of a thread pool, which takes the following input a) Size of the pool to be constructed b) Name
of the class which implements
Comments: 1

Last Update: June 16, 2005 By Pankaj Dwivedi

Answer

Added: June 16, 2005

164.
What
are
the
primitive
types
According to Java in a Nutshell, 5th ed boolean, byte, char, short, long float, double, int
Comments: 1
165.

the

Last Update: June 03, 2005 By joadavis

Answer

in

Java

Added: June 03, 2005

Does JVM maintain a cache by itself? Does the JVM allocate objects in heap? Is this
OS
heap
or
the
heap
maintained
by
the
JVM?
Why

yes the JVM maitain a cache by itself.No it allocates the objects in stack ,in heap on references
1. What
is
metadata?
A single application can have one or more connections with a single database, or it can have
connections with many different databases.A user can get information about a Connection object's
database by invoking the Connection.getMetaData method.
Added: October 20,
Comments: 6 Last Update: November 14, 2005 By Mamatha Answer
2005

if 4 different drivers are loaded, & created 4 different statements calling diffener tables
from same database, how driver is recognized for each statement?
2.

AND, The DriverManager attempts to select an appropriate driver from the set of registered JDBC drivers
Added: October
Comments: 4 Last Update: November 09, 2005 By Jackie Answer
2005
3. how
many
no upper bound
Comments: 1

statements

can

be

Last Update: October 31, 2005 By manikant

created
Answer

with

one
Added:
2005

18,

connection
October

18,

4. which is the best driver among the 4 jdbc drivers?how can we load that driver?
Type 4 is the best driver because it directly interact with database without any usage od intermediate serversor
other technology.Because of this reason Type-4 driver is also called Thin Driver
Added: October 17,
Comments: 2 Last Update: October 24, 2005 By Mamatha Answer
2005
5. why do we use prepared statement when already statement is present
Actually when u submit a simple statement to the databse, at first the DBMS parses it and sends it back with
the result, so again when u send the same statement again the DBMS server parses it and sends back the
result so here a lot of time is wasted
Added: October 13,
Comments: 3 Last Update: October 24, 2005 By mamatha03 Answer

2005
6. how
can
store
images
in
a
data
base?
Using binary streams (ie getBinaryStream() ,setBinaryStream()).But it is not visable in database ,it is stored in
form of bytes ,to make it visable we have to use any one frontend tool.
Added: October 03,
Comments: 2 Last Update: October 23, 2005 By Mamatha Answer
2005
7. How
to
get
the
resultset
of
stroedProcedure
Invove getResultSet() method of the callableStatement object which is inherited from java.sql.Statement
interface
Added: October 03,
Comments: 2 Last Update: October 18, 2005 By Ramesh Answer
2005
8. Difference
between
Type-2
and
Type-3
driver
Type-2 driver is Part Java Part Native Driver. This driver is a mixture of Jdbc driver and Vendor speciifc driver .
You not only use ODBC to communicate with DataBase. You can also use Vendor specif Apis like Oracle Call
Level Interface (OCI) that is
Added: September 21,
Comments: 2 Last Update: October 24, 2005 By mamatha03 Answer
2005
9. "select * from user" .what are the steps to take for execution of query in JDBC?
in java program if we want execute a statment 1) load the driver by using Class.forname("driver")2) get
connection by using driverManager.getConnection("DataSource")3) createStatement con.createStatement();4)
execute the query n get resultset.
Added: September 18,
Comments: 2 Last Update: November 12, 2005 By ss Answer
2005
10. What
is
the
purpose
of
setAutoCommit(
)
The method is used to determine whether any transaction made by executeUpdate() to be saved into the
database. By default, status is true, i.e., transacations are saved. By setting autocommit to false using
setAutocommit(false) you ask the JDBC
11. What
is
a
transaction
Answered by anoop shukla on 2005-05-02 10:33:27: transaction is collection of logical operation that
perform a task
Added: September 08,
Comments: 13 Last Update: October 04, 2005 By madhav Answer
2005
12. What
is stored procedure. How do you create stored procedure
Stored Procedure is an object design with business logic and stored in the database .Since it stays in the
database ,the execution of the business logic is more faster...
Added: September 07,
Comments: 9 Last Update: October 12, 2005 By Hameed Answer
2005
13. What
is
the
difference
between
Resultset
and
Rowset
If the connection is alive, then only the values remain in a ResultSet, where as in RowSet,once we get the
results connection need not be alive.
Added: September 05,
Comments: 9 Last Update: October 15, 2005 By sudhakar Answer
2005
14. What
is
the
difference
between
JDBC
1.0
and
JDBC
Also JDBC2.0 provides extended support for transactions that includes batch updates and savepoints
Added: August
Comments: 3 Last Update: August 31, 2005 By Prasanna V V Answer
2005

2.0
31,

15. What
is
Connection
Pooling
Connection pooling means set of connections are available to connect, after use this connection, disconnect it
then others can use it.It reduce the time, and it can be reusable.Any number of connections can be used by
user.
Added: August 26,
Comments: 7 Last Update: October 18, 2005 By safiya Answer
2005
16. What are the three statements in JDBC & differences between them
Answered by Jey on 2005-05-10 05:53:50: 1.Statement which is used to run simple sql statements like select
and update 2. PrepareStatment is used to run Pre compiled sql. 3. CallableStatement is used to execute the
stored procedures.
Added: August 26,
Comments: 8
Answer
2005
17. What
is
JDBC
Driver
interface?
The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the
JDBC
API.
Each
vendors
driver
must
provide
implementations
of
the
java.sql.Connection,Statement,PreparedStatement, CallableStatement, ResultSet
Added: August 23,
Comments: 2 Last Update: August 23, 2005 By Ravi Answer
2005
18. What
Class.forName(
)
method
will
do
Answered by Jey Ramasamy on 2005-05-10 05:50:07: Class.forName() is used to load the Driver class which
is used to connect the application with Database. Here Driver class is a Java class provided by Database
vendor.
Added: August 08,
Comments: 10 Last Update: October 04, 2005 By abhishek Answer
2005
19. What
are the steps for connecting to the database using JDBC
Answered by Jey on 2005-05-10 06:01:10: Here are the steps. Using DriverManager: 1. Load the driver class
using class.forName(driverclass) and class.forName() loads the driver class and passes the control to
DriverManager class 2.DriverManager.getConnection()
Added: August 01,
Comments: 5 Last Update: October 18, 2005 By safiya Answer
2005

While in CallableStatament using in the oracle my procedure is return no.of columns so


in java how can i retrivbe the data and i wnat to view all data which is reetrive from my
procedure
20.

hi
21. How
to
call
a
Stored
Procedure
from
JDBC?
The first step is to create a CallableStatement object. As with Statement an and PreparedStatement
objects, this is done with an open Connection object. A CallableStatement object contains a call to a
stored procedure;E.g.CallableStatement cs = con.prepareCall("{call
Comments: 2

Last Update: September 23, 2005 By

Cheedella Answer

Chidambara Gupta.

Added: July 16, 2005

22. What
Class.forName
will
do
while
loading
drivers?
It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a
driver, it is available for making a connection with a DBMS.
Added: July 16, 2005
Comments: 3 Last Update: October 17, 2005 By M.Nithiyanandhan Answer
23. What
packages
are
used
by
JDBC?
There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement,
ResultSet, ResultSetMetaData, DatabaseMetaData.

Comments: 2

Last Update: October 04, 2005 By geetha

Answer

Added: July 16, 2005

24. What
is
JDBC?
JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a
different database engine and to write to a single API. JDBC allows you to write database applications in Java
without having to concern yourself
Comments: 2

Last Update: September 22, 2005 By

Chidambara Gupta.

Cheedella Answer

Added: July 16, 2005

25. What
are
the
common
tasks
of
JDBC?
Create an instance of a JDBC driver or load JDBC drivers through jdbc.driversRegister a driverSpecify a
databaseOpen a database connectionSubmit a queryReceive results
Comments: 1

Last Update: July 12, 2005 By Prass

Answer

Added: July 12, 2005

26. How
can
you
make
the
connection?
In establishing a connection is to have the appropriate driver connect to the DBMS. The following line of code
illustrates
the
general
idea:E.g.String
url
=
"jdbc:odbc:Fred";Connection
con
=
DriverManager.getConnection(url, "Fernanda", "J8");
Comments: 1

Last Update: July 06, 2005 By kk

Answer

Added: July 06, 2005

27. How
do
you
implement
Connection
Pooling
code for connecting the connection poolingInitalContext ic=new InitialContext();Hashtable ht=new
Hashtable();ht.put("Context.INITIAL_PROVIDER",weblogic.jndi.InitialCla) //u have to set weblogic properties
first and the jndi name that u r defining in //weblogic
Comments: 3

Last Update: October 06, 2005 By G.kirankumar

Answer

Added: June 26, 2005

28. What
are
the
different
types
of
Statements?
1.Statement (use createStatement method) 2. Prepared Statement (Use prepareStatement method) and 3.
Callable Statement (Use prepareCall)
Added: June 02, 2005
Comments: 1 Last Update: June 02, 2005 By Sreekanth Answer
29. How
can
you
retrieve
data
from
the
ResultSet?
First JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to
hold our results. The following code demonstrates declaring the ResultSet object rs.E.g.ResultSet rs =
stmt.executeQuery("SELECT COF_NAME, PRICE
Comments:
2 Last
Update:
September
29,
2005
By
Siladitya
Added: June 02, 2005
Chatterjee Answer
30. What
are
the
flow
statements
of
JDBC?
A URL string -->getConnection-->DriverManager-->Driver-->Connection-->Statement-->executeQuery->ResultSet.
31. What
are
batch
updates
Batch Updates are nothing but a bunch of updations that are done at a time without interruption. All
the update statements are added to a Batch by using the addBatch() method and the Batch is executed
by using the executeBatch() method. These
Comments: 3 Last Update: September 21, 2005 By Chidambara Gupta.
Added: April 16, 2005
Cheedella Answer
32. What
are
the
two
major
components
of
JDBC?
One implementation interface for database manufacturers, the other implementation interface for application
and applet writers.
Comments: 1 Last Update: September 22, 2005 By Chidambara Gupta. Added: August 27,
2004

Cheedella Answer
33. What
are
the
steps
involved
in
establishing
This involves two steps: (1) loading the driver and (2) making the connection.
Comments:

Last

Update:

September

19,

2005

By

Navnish

Sharma Answer

Added:
2004

connection?
August

27,

34. How
can
you
load
the
drivers?
Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example,
you
want
to
use
the
JDBC-ODBC
Bridge
driver,
the
following
code
will
load
it:Eg.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Your driver
Added: August 27,
Comments: 2 Last Update: October 26, 2005 By Ashwini Answer
2004
35. How
can
you
create
JDBC
statements?
A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and
then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a
SELECT statement, the method to use is executeQuery.
Added: August 27,
Comments: 1 Last Update: October 22, 2005 By saadu Answer
2004
36. How
can
you
use
PreparedStatement?
This special type of statement is derived from the more general class, Statement. If you want to execute a
Statement object many times, it will normally reduce execution time to use a PreparedStatement object
instead. The advantage to this is that in
Comments: 1

Last Update: September 23, 2005 By

Chidambara Gupta.

Cheedella Answer

Added:
2004

August

27,

37. How
to
Retrieve
Warnings?
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do
not stop the execution of an application, as exceptions do; they simply alert the user that something did not
happen as planned. A warning can be reported
Added: August 27,
Comments: 0
Answer
2004
38. How
to
Make
Updates
to
Updatable
Result
Sets?
Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java
programming language rather than having to send an SQL command. But before you can take advantage of
this capability, you need to create a
1. In which pattern does all the action classes in the struts are organized
please post the answer
Added: November 03,
Comments: 4 Last Update: November 10, 2005 By sridhar kalluru Answer
2005
2. What
is the actual difference between MVC and MVC Model2
MVC1 - There will one dedicated controller which will interact with model and produces the viewMVC2- There
will be a centralized controller which delegates the request to specific (Action) controller. The action controller
interacts with model and
Added: October 16,
Comments: 7 Last Update: November 11, 2005 By Karthik Answer
2005
3. how
can
pl any one answer
Comments: 3

pass

info

from

dyna

form

Last Update: November 03, 2005 By ramakrishna

bean

to

Answer

Entity

Bean(CMP)

Added: September 27,

2005
4. how
to
need answer
Comments: 2

build

struts

in

java?what

are

Last Update: November 09, 2005 By Rajiv Kumar

the
Answer

function

of

struts?

Added: September 27,


2005

When we are saving form bean ,What is the difference between session scope and
request
scope.
5.

I dont know
Comments: 7

Last Update: November 05, 2005 By Shailesh

Answer

Added: September 27,


2005

6. Can we use any other technology than JSP to construct a view ?


Yes, other than JSP we can use Swing, JSF, Cocoon etc as a front end for our struts application. Here is a link
to the article for using struts with swing as front end
Added: September 21,
Comments: 1 Last Update: October 31, 2005 By bharath Answer
2005
7. Does
Struts provide support for Validator & Tiles by default ?
No, These features are turned off by default. One has to enable the plugins by properly inserting entries in
Struts-config.xml
Added: September 21,
Comments: 0
Answer
2005
8. can
i
no it is not possible
Comments: 1

use

bc4j

with

Last Update: November 11, 2005 By vishwadeep

spring
Answer

framwork

Added: September 21,


2005

Is there any way to put my custom name to LIB folder which i am going to place in
WEB-INF
folder
of
struts
application?
9.

please answer this question


Comments: 3

Last Update: November 14, 2005 By ravi

Answer

Added: September 12,


2005

How you will save the data across different pages for a particular client request
usingStruts
10.

Create an appropriate instance of ActionForm that is form bean and store that form bean in session scope. So
that it is available to all the pages that for a part of the request
11. What
is
Struts
Answered by asreeni on 2005-04-08 03:24:40: The core of the Struts framework is a flexible control
layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as
well as various Jakarta Commons packages. Struts encourages
Added: September 07,
Comments: 18 Last Update: October 31, 2005 By Francis Answer
2005
12. Explain
Struts
navigation
flow
The Struts Flow is like this the very first request comes to the Action servlet which the part of the Controller
component of the MVC architeture , then the requets is disptachted to the request processor the request
processor find the specified
Added: September 04,
Comments: 4 Last Update: November 12, 2005 By Rohit Ankushe Answer 2005

13. What
is the difference between ActionForm and DynaActionForm
Dyna Action is a Generic action form which represents a form.properties of the form are decided at the timeof
deplying the application.Where as in Action form form field propertie are decided when we develop the
application ,there is no chance if in future
Added: September 03,
Comments: 9 Last Update: October 31, 2005 By prabhaker Answer
2005
14. What
part
of
MVC
does
Struts
represent
Struts is purely the controller ie the action servlet where the action servlet is responsible for giving
the business logic .
Added: August 30,
Comments: 5 Last Update: August 30, 2005 By Sandeep Katiyar Answer
2005
15. What
are
the
Important
Components
of
Struts?
1. Action Servlet2. Action Classes3. Action Form4. Validator Framework5. Message Resources6. Struts
Configuration XML Files7. View components like JSP
Added: August 23,
Comments: 1 Last Update: November 09, 2005 By Anindit Sinha Answer
2005
16. What
is
DispatchAction
DispatchAction is mostly used for carrying out multiple operations with in a single Action class. Here is the link
to some article that I found on this:http://www.reumann.net/struts/lesson3/step6.do
Added: August 23,
Comments: 3 Last Update: September 13, 2005 By LV Answer
2005
17. What
are
the
various
c.tldfmt.tldsql.tldbean.tldhtml.tldtiles.tldlogic.tldtemplate.tld
Comments: 3
18.

Struts

Last Update: October 20, 2005 By sathanantham

Answer

tag
Added:
2005

libraries
August

23,

What is the purpose of tiles-def.xml file, resourcebundle.properties file, validation.xml

file
This validation.xml configuration file defines which validation routines that is used to validate Form Beans. You
can define validation logic for any number of Form Beans in this configuration file. Inside that definition, you
specify the validations
Added: August 14,
Comments: 3 Last Update: August 13, 2005 By Deepak Answer
2005
19. What
is
the
difference
between
Struts
1.0
and
Struts
1.1
The main differences are 1. In Action class Perform() method was replaced by execute() method.2.
DynaActionForms are added.3. Tiles Concept is introduced.4. We can write our own Controller by
Inheriting RequestProcessor class. i.e., nothing but we
Comments: 6

Last Update: September 23, 2005 By

Chidambara Gupta.

Cheedella Answer

Added:
2005

August

06,

20. How
to
call
ejb
from
Struts
we can use the interceptor pattern to call ejb from the struts it also works goodthnaks and regardsramanujam
21. How
you
will
handle
errors
and
exceptions
using
Struts
Strust provides ActionError object. Store each error msg by converting them to ActionErrors obj. Then
save this obj in the request by calling saveError method of the ActionServlet.In the JSP use tag to
show the error msg.
Added: July 15, 2005
Comments: 5 Last Update: October 04, 2005 By Anant Answer
22.

What

are

the

core

classes

of

struts?

The core classes of struts are ActionForm, Action, ActionMapping, ActionForward etc.
Comments: 1

Last Update: July 12, 2005 By kishore

Answer

Added: July 12, 2005

23. What
is Action Class. What are the methods in Action class
Action class in which define which action has to be taken for this all forword condition create there.Action class
have a Execute() method.
Added: July 11, 2005
Comments: 4 Last Update: October 05, 2005 By Govind Answer
24. Explain
about
token
feature
in
Struts
Another important usage of tokens is to trap an event when the user hits the "Submit" button twice. Tokens
allows to prevent duplicate processing for such a request.
Comments: 2

Last Update: July 07, 2005 By Manoj

Answer

Added: July 08, 2005

25. What we will define in Struts-config.xml file. And explain their purpose
We will define Data-source[for database connectivity],Action Mappings[for action input and next output],Action
Forward[global forward],Action Errors etc....
Added: May 08, 2005
Comments: 4 Last Update: October 14, 2005 By chirag desai Answer
26. What
is the difference between ActionErrors and ActionMessages
Hi Friends,
ActionErrors and ActionMessages are same but in the struts-config.xml file if you are given
the input in action tag and If action errors object is not empty
1. 1. How EjbQL ara impemented when it is necessary?2.what do you mean by shared transactional
state data maintained by EJB?3.what do you mean by CMP & BMP &what is besic ifference between
them?4.where are databese maneged by Entity bean is implemented & how many instance of the Entity
bean for each client is maintained by Ejb container?please describe ths question conceptually?5.whuy
BMP
class
returns
EJBQL is implemented using the XML file "ejb-jar.xml" file. We will use certain tags in the "EJB-Jar"
file to implement EJBQL.
Added: November 06,
Comments: 2 Last Update: November 10, 2005 By Ramarao A.V. Answer
2005
2. why
we
need
the
transactions?
In critical applications dealing with data ,the application has to ensure that the logical work done on the data
leaves it in a consistent state .Tranascations are required to ensure that either the data is completely modified
or if some problem occurs
Added: October 29,
Comments: 1 Last Update: November 04, 2005 By Hameed Answer
2005
3.
What
is
an
EJB
Context?
EJBContext is an interface that is implemented by the container, and it is also a part of the bean-container
contract. Entity beans use a subclass of EJBContext called EntityContext. Session beans use a subclass
called SessionContext. These EJBContext
Added: October 25,
Comments: 0
Answer
2005

how to transfer a bulk amount of tabular data from a jsp page to an ejb thru a servlet and
viceversa
4.

First of all, I don't quite get what you mean by tabular data.Please explain in detail.Anyway, if you want to send
huge amount of data from the jsp to an ejb via servlet what you can do is write a data-object class where you
declare a certain number of
Comments:

Last

Dasgupta Answer

Update:

November

04,

2005

By

Ratul

Added:
2005

October

19,

5. what
is
difference
between
servlet
and
jsp
JSP is Java code embedded in HTML; the Java code is compiled (if necessary) and run by the container on
the server and the client only sees the results of that code's execution mixed in appropriately with the
html.Servlets are compiled pure Java class
Added: October 13,
Comments: 1 Last Update: October 22, 2005 By pranuthi Answer
2005
6. what
is
requestdespatcher?
It is a method that gives object to which next request ,response objects need to be handled to serve the left
over work.
Added: October 13,
Comments: 1 Last Update: October 22, 2005 By Srikanth Answer
2005
7. how
garbage
collector
works
garbage collector collects all the unreachable objects and because of this clens up the memory which is used
by unreachable objects
Added: October 09,
Comments: 1 Last Update: October 28, 2005 By sridevi Answer
2005

i created a bean with source code, mft and jar.but even after creating the jar file the bean
component is not found on the tool box.an error occurs stating that the jar file could not
find the bean in the mft file.
8.

Comments: 0
9.
d

Added:
2005

Answer

October

07,

what is business delicate ? Use ? and what is session faced ? use ?

Comments: 1

Last Update: October 28, 2005 By vemodhara

Answer

Added: September 18,


2005

10. what
is
design
pattern
?
use
?
A design pattern describes a recurring desing problem and a core solution to it. A design pattern has 4
essential elements: a name, the problem, the solution and consequences. Design patterns can be grouped in
3 major categories: creational, structural
11. Give a scenario where you have used stateless session beans and why was it necessary?
Hi All,The stateless bean is used whereever the logic does the same for all client irrespective of
remembering the client state.For Example, Consider a simple EJB Client which just converts dollar to
ruppee value. So as per logic, it does not matter who
Added: September 15,
Comments: 3 Last Update: November 01, 2005 By Vijay Answer
2005
12. What
are
the
call
back
methods
in
Session
bean
Answered by Jey on 2005-05-08 19:41:22: Session bean callback methods differ whether it is Stateless or
stateful Session bean. Here they are. Stateless Session Bean 1. setSessionContext() 2. ejbCreate() 3.
ejbRemove() Stateful
Added: September 09,
Comments: 6 Last Update: October 01, 2005 By sasikumar Answer
2005
13. What is Session Bean. What are the various types of Session Bean
Answer posted by Mohan on 2005-05-20 08:44:39: SessionBeans typically are used to represent a client they
are of two typse Stateful Session Beans : they maintain conversational state between subsequest calls by a
client Stateless
Added: September 05,
Comments: 9 Last Update: October 17, 2005 By Balakrishnan Answer
2005

14. What
is the difference between normal Java object and EJB
The world can exist without EJBs! But the basic purpose of writing EJBS is to save a programmer the effort of
writing middleware services like transaction services, security, network services etc. Thankfully, a server that
conforms to J2EE specifications
Comments:

16

Last

Update:

October

20,

2005

By

Ratul

Dasgupta Answer

Added: September 05,


2005

15. How
to insert
new
row
and link
like
Edit
and Delete
You can use two methods like insertRow() and deleteRow() of ejbCreate() for insert and delete the data from
the data base in entity Bean.
Added: September 03,
Comments: 1 Last Update: September 27, 2005 By Rajnish Sasmal Answer 2005
16. Can
a
Session
Bean
be
defined
Answer posted by Mohan on 2005-05-21 19:27:35: No
Comments: 7

Last Update: November 10, 2005 By kripa

without

ejbCreate()

method

Added: September 03,


2005

Answer

17. Why
does EJB needs two interfaces(Home and Remote Interface)
Actually Home interface are used as a Factory to get Bean reference. However since the Bean class/object is
not available to the client it uses the remote interface to hold the bean reference
Added: September 03,
Comments: 7 Last Update: November 12, 2005 By abhi Answer
2005
18. What
is
EJB
Query
Language
Here also we can write a complex query(complex select and find method) in our containen managed entity
bean.
Comments: 4 Last Update: November 03, 2005 By Mannu Kumar Added: September 03,
2005
Pandey Answer
19. Can
I
invoke
Runtime.gc()
Answer posted by Mohan on 2005-05-21 19:26:48: No
Comments: 2

Last Update: September 02, 2005 By Dinesh

in

an

EJB

Added: September 02,


2005

Answer

20. What
is
local
interface.
How
values
will
be
passed
Answered by Jey on 2005-05-08 12:33:35: If Client and EJB classes are in the same machine ( Same JVM)
then we can use Local linterface instead of Remote interface. Since Client and EJB are in same JVM, values
are passed by referance.
21. What is the difference between Stateful session bean and Stateless session bean
Answer posted by Mohan on 2005-05-20 08:45:36: Stateful session beans have the passivated and
Active state which the Stateless bean does not have.
Added: August 27,
Comments: 5 Last Update: October 03, 2005 By stephen Answer
2005
22. How
statefull
session
bean
remembers
Through its convesational state, may be a member variable of the bean
Comments: 2

Last Update: September 12, 2005 By venkateswarlu

it's

Answer

client
Added:
2005

state
August

15,

23. What
is
the
difference
between
JavaBean
and
EJB
Answer posted by Mohan on 2005-05-20 08:40:04: Java Beans is intra-process component where as EJB is
an Inter-Process component JavaBeans is particularly well-suited for asynchronous, intra-application
communications among software

Comments: 8

Last Update: October 21, 2005 By Jane

24. How
can
we
call
We can call java beans by using jsp:useBean tag
Comments: 2

Last Update: August 04, 2005 By sri

Added:
2005

Answer
java

Answer

beans

August

in
Added:
2005

05,

jsp?
August

04,

Can we use instance variables in Stateless session beans? If yes, Why and How? If the
answer
is
no
,
explain
why
and
how?
25.

no,In Stateless it does not maintain the contexual information about the client.In statefull we are having the
ejbActivate(),ejbPassivate() bcoz it maintains the user specific data. but if we are giving the activation and
passivation in stateless the
Added: July 31, 2005
Comments: 2 Last Update: September 30, 2005 By gokulakrishnan Answer
26. what is the difference between distributed transactions and Flat transactions in EJB?
Distributed transaction are executed in a distributed manner (may on more than one machine) while flat are
not having this feature.
Comments: 2 Last Update: November 03, 2005 By Mannu Kumar
Added: July 30, 2005
Pandey Answer
27. What
are
the
optional
clauses
in
EJB
QL
According to EJB 2.1 specificationThe EJB QL consists of 4 clauses: SELECT, FROM(mandatory) WHERE
and ORDER BY(optional).
Comments: 3

Last Update: July 29, 2005 By khan

Answer

Added: July 29, 2005

28. When you will chose Stateful session bean and Stateless session bean
Stateful session beans are used when there is converstional state and when there is a need of temporary
storage Stateless session bean are used when there is no conversational state and when session bean has to
be used only for database acce
Comments: 4

Last Update: July 29, 2005 By divya

Answer

Added: July 29, 2005

29. What
is
EJB
EJB ia a server-side component architecture that simplifies the process of building enterprise-class distributed
application components in java.
Added: July 29, 2005
Comments: 8 Last Update: November 11, 2005 By krishna Answer
30. How do you check whether the session is active in Stateful session bean
In Stateful session bean session is not itself a separate entity. it is contained in the bean it self. So in order to
check tht we need the check whether the Stateful session bean is present or not which is done by just invoking
the home interface with
31. What
is
the
difference
between
HTTPSession
and
Stateful
Session
Bean
Session Bean comes with the implicit services where as HHTPSession does not. Session Bean can
be web based or can be stand alone where the other can only be web based. Session Bean can be
used for multiple operation for a single
Added: July 28, 2005
Comments: 2 Last Update: July 28, 2005 By J. P. Naidu Answer
32. What are the various isolation levels in a transaction and differences between them
Answered by Jey on 2005-05-08 19:35:35: There are three isolation levels in Transaction. They are 1. Dirty
reads 2.Non repeatable reads 3. Phantom reads. Dirrty Reads If transaction A updates a record in database
followed by the transaction
Added: July 28, 2005
Comments: 2 Last Update: July 28, 2005 By J. P. Naidu Answer

33. What
is
the
main
use
of
using
interface?
Interface is mainly used to seperate the server side business logic from the client. Because interface contains
only the method defination which is getting exposed to the client. Hence if one modifies the coding in the
serverside business logic, no change
Comments: 2

Last Update: September 14, 2005 By Partha Mandal

Answer

Added: July 25, 2005

34. What
is
ACID
Answered by Jey on 2005-05-08 17:27:45: ACID is releated to transactions. It is an acronyam of Atomic,
Consistent, Isolation and Durable. Transaction must following the above four properties to be a better
one Atomic: It means a transaction
Comments: 2

Answer

Last Update: July 25, 2005 By Ritesh patni

Added: July 25, 2005

35. What
is
the
difference
between
CMP
and
BMP
Answered by Jey on 2005-05-08 11:32:16: CMP means Container Managed Persistence. When we write CMP
bean , we dont need to write any JDBC code to connect to Database. The container will take care of
connection our enitty beans fields with database. The
Comments: 4

Answer

Last Update: November 01, 2005 By Anitha

Added: July 25, 2005

36. What is Entity Bean. What are the various types of Entity Bean
Answered by Jey on 2005-05-08 12:47:06: Entity bean represents the real data which is stored in the
persistent storage like Database or file system. For example, There is a table in Database called Credit_card.
This table contains credit_card_no,first_name
Comments: 4

Answer

Last Update: July 25, 2005 By Ritesh Patni

Added: July 25, 2005

37. What
is
the
life
cycle
of
Stateless
session
bean
1. dose not exsist 2. exsist to start the session set the sessionContext() call create() to end session call
remove
Added: July 24, 2005
Comments: 2 Last Update: July 24, 2005 By pradeep Answer
38. What
is
the
life
cycle
of
Stateful
session
bean
1. doesnot exsist 2. exsists 3. passivate invoke ejbcreate() set the sessioncontext() call create() if the session
idle call ejbPassivate() to get back to session call ejbActivate() to end the
Comments: 2

Last Update: July 24, 2005 By pradeep.gt

Answer

Added: July 24, 2005

39. What
is
the
difference
between
ejbStore()
and
ejbLoad()
Answered by Jey on 2005-05-08 11:06:46: When the EJB container needs to synchronize the instance
variables of an entity bean with the corresponding values stored in a database, it invokes the ejbLoad and
ejbStore methods. The ejbLoad method refreshes
Comments: 3

Last Update: July 22, 2005 By Vj

Answer

Added: July 22, 2005

40. Does
Stateful
Session
bean
support
instance
pooling
Answer posted by Mohan on 2005-05-21 19:24:23: All Beans support Instance Pooling
41. How
many
EJB
Objects
are
created
for
a
Bean
Only one Object Created for a bean.
Comments: 1 Last Update: July 22, 2005 By Venkata Subbarao
Added: July 22, 2005
Bathula Answer
42. What is clustering. What are the different algorithms used for clustering
A cluster is loosely coupled group of servers that provide a unified, simple view of the services that they offer
individually. Servers in a cluster may or may not communicate to one another. Generally, the overall goal of
employing a cluster is to increase
Added: July 21, 2005
Comments: 1 Last Update: July 21, 2005 By srisubu Answer

43. Why
CMP
beans
Its actual implementation is done by the Container.
Comments: 2

are

Last Update: July 20, 2005 By Amitav C

abstract

Answer

classes?

Added: July 21, 2005

Can I develop an Entity Bean without implementing the create() method in the home
interface
44.

Yes, you can create entity bean without impelementing the create() method. The ejbs will be instantiated by
findByPK or any finder methods.
Comments: 1

Last Update: July 20, 2005 By Ginni

Answer

Added: July 21, 2005

Why are ejbActivate() and ejb Passivate() included for stateless session bean even
though
they
are
never
required
as
it
is
nonconversational
bean
45.

To have a consistent interface, so that there is no different interface that you need to implement for Stateful
Session Bean and Stateless Session Bean. Both Stateless and Stateful Session Bean implement
javax.ejb.SessionBean and this would not be possible
Comments: 1

Last Update: July 20, 2005 By Ginni

Answer

Added: July 21, 2005

46. How to implement an entity bean which the PrimaryKey is an autonumeric


If you mean, auto generated primary key with values as numeric. This can be acheived in EJB 2.0 by using
tag. You need to define and to specify how the keys are generated. If generation type is 'ORACLE',
generation-name should be the Oracle
Comments: 1

Last Update: July 20, 2005 By Ginni Gandhi

47. Is
Decorator
an
Decorator is not a EJB Design pattern. It is a Java pattern.
Comments: 2

Last Update: July 20, 2005 By JavaPerson

Answer
EJB

Added: July 21, 2005

design

Answer

pattern

Added: July 21, 2005

48. How
is Stateful Session bean maintain their states with client
stateful beans maintains their state through instance variables. the values of the instance variables is specific
to client. when the bean instance needs to be removed from the pool (usually LRU replacement) , the state is
passivated to secondary storage.
Comments: 2

Last Update: September 19, 2005 By Ravi Dalal

49. Can
i
map
more
than
Its
possible
to
map
more
than
one
tables
docs.bea.com/wls/docs81/faq/ejb.html#260273
Comments: 2

Last Update: September 14, 2005 By Saket

If
session
has
thrown
EJBContext.setRollBackOnly
50.

one
to a

Answer

Added: July 18, 2005

table
CMP.

Answer

ApplicaitonException

in
Have

CMP

look

athttp://e-

Added: July 18, 2005

would

you
use
method

yes
51. How will you propagate exception thrown inside session bean to JSP or Servlet client
2 types of exceptions can occur 1.System Exception - We can define some error codes the in the
property file and show it to the JSP 2.Application Exception.. - We can customise the exception and
show the appropriate error
Added: July 18, 2005
Comments: 1 Last Update: July 18, 2005 By Srinivas Jadcharla Answer
52. What
are
the
services
provided
by
container
The EJB container provides services to EJB components. The services include transaction, naming, and
persistence support. Transaction support An EJB container must support transactions. EJB specifications
provide an approach to transaction

Comments: 1

Last Update: July 18, 2005 By Srinivas Jadcharla

Answer

Added: July 18, 2005

53. What
is
difference
between
EJB
1.1
and
EJB
2.0
Answered by Jey on 2005-05-08 12:51:03: EJB 2.0 adds the local beans, which are accessible only from
within the JVM where beans are running in. In EJB 1.1, we had to implement remote client views for all these
beans, even if we had no remote
Added: July 17, 2005
Comments: 4 Last Update: October 10, 2005 By suman medisetti Answer
54. What
are simple rules that a Primary key class has to follow
Primary key class has to meet the following requirements
The access control modifier of the class is
public.
All fields are declared as public.
Comments: 3

Last Update: September 20, 2005 By Sailaja

Answer

Added: July 15, 2005

55. What
is the difference b/w sendRedirect()
and <jsp: forward>?
we can use when we want to forward a page with in the context. using sendRedirect() method we can forward
to jsp which is in another context also. And in there will be only one request procesed between client and
server whereas in sendRedirect() there
Comments: 2

Last Update: July 12, 2005 By KishoreDVS

Answer

Added: July 12, 2005

If i throw a custom ApplicationException from a business method in Entity bean which


is participating in a transaction, would the transaction be rolled back by container. Does
container
rolls
back
transaction
only
in
case
of
SystemExceptions
56.

Answer posted by Mohan on 2005-05-21 17:21:54: yes the rollback will occur
Comments: 2

Last Update: June 30, 2005 By Denis Wang

Answer

Added: June 30, 2005

57. What
is
abstract
schema
Answer posted by Mohan on 2005-05-21 18:34:01: CMP uses abstract schema to map to the physical
database
Added: June 27, 2005
Comments: 2 Last Update: June 27, 2005 By Ashok Answer
58. What
is
handle
in
EJB
A handle is an abstraction of a sreference to an EJB object. A handle is intended to be used as a "robust"
persistent reference to an EJB object.
Comments: 2

Last Update: June 27, 2005 By Ashok

Answer

Added: June 27, 2005

59. What
is the difference between find and select methods in EJB
A select method is similar to a finder method for Entity Beans, they both use EJB-QL to define the semantics of
the method. They differ in that an ejbSelect method(s) are not exposed to the client and the ejbSelect
method(s) can return values that
Comments: 2

Last Update: June 27, 2005 By Ashok

Answer

Added: June 27, 2005

60. What is the difference b/w weblogic8.1 server and its earlier versions?
61. what happens while we interacting with page and immediately database fails?
Comments: 0

Answer

Added: June 26, 2005

62. How
can
we
call
cmp?
First of all the question is not very clear and specific. But I hope this helps:You call create() method of the
home object which in turn calls the ejbCreate() of the bean and as you mentioned that this a CMP - so within
the beans ejbCreate() you can
Comments: 1

Last Update: October 31, 2005 By Jignesh

Patel Answer

Added: June 26, 2005

63. What
is
Instance
pooling
pooling of instances. in stateless session beans and Entity Beans server maintains a pool of
instances.whenever server got a request from client, it takes one instance from the pool and serves the client
request.
Comments: 1

Last Update: June 14, 2005 By suresh chowdary

Answer

Added: June 14, 2005

64. Is
instance
pooling
necessary
for
entity
beans?
One of the fundamental concepts of Entity Beans is that they are the pooled objects.Instance pooling is the
service of the container that allows the container to reuse bean instances,as opposed to creating new ones
every time a request for a bean is
Comments: 1

Last Update: June 03, 2005 By RajeshRokkam

Answer

Added: June 03, 2005

When two entity beans are said to be identical?Which method is used to compare
identical
or
not?
65.

Two Entity Beans are said to be Identical,if they have the same home inteface and their primary keys are the
same.To test for this ,you must use the component inteface's isIdentical() method.
Added: June 03, 2005
Comments: 1 Last Update: June 03, 2005 By RajeshRokkam Answer
66. Can undefined primary keys are possible with Entity beans?If so, what type is defined?
Yes,undefined primary keys are possible with Entity Beans.The type is defined as java.lang.Object.
Added: June 03, 2005
Comments: 1 Last Update: June 03, 2005 By Rajesh Rokkam Answer
67. What
are
advantages
and
disadvantages
of
CMP
and
BMP
CMP:: Advantages: 1)Easy to develop and maintain. 2)Relationships can be maintained between different
entities. 3)Optimization of SQL code will be done. 4)Larger and more performance applications can be
done. Disadvantages
Added: June 02, 2005
Comments: 1 Last Update: October 28, 2005 By RajeshRokkam Answer
68. When
you
will
chose
CMP
and
BMP
When ever you want to use SAP or any ERP concept for ur back end then it is better to go for BMP's .If u are
very particular about the performance of application then better use BMP rather than using CMP.
Comments: 3

Last Update: October 28, 2005 By gskumar

Answer

Added: June 02, 2005

69. What is the difference between optimistic locking and pessimistic locking
Answer posted by Mohan on 2005-05-21 17:20:02: Optimistic locking assumes that no one would read or
change the data while changes are being by a bean Pessimistic locking would rather lock down the data so
that no one can access it
Comments: 2

Last Update: May 27, 2005 By John

Answer

Added: May 28, 2005

70. What
is the difference between ejbCreate() and ejbPostCreate()
Answered by Jey on 2005-05-08 11:14:33: Session and Message Driven Bean will have only ejbCreate()
method and no ejbPostCreate() method. Entity bean will have both ejbCreate() and ejbPostCreate()
methods. The ejbPostCreate method returns void
71. With EJB 1.1 specs, why is unsetSessionContext() not provided in Session Beans, like
unsetEntityContext()
in
Entity
Beans
This was the answer Provided by some one... According to Mohan this one is not correct. Please
see Mohan's reply below and more in the comments section. ejbRemove() is called for session beans
every time the container destroyes the bean. So
Added: May 21, 2005
Comments: 2 Last Update: May 21, 2005 By Mohan Answer
72. What
is
the
difference
between
CMP
1.1
and
CMP
2.0
Answer posted by Mohan on 2005-05-21 17:15:36: CMR and sub classing of the CMP bean by the container

Comments: 1

Last Update: May 21, 2005 By Mohan

Answer

Added: May 21, 2005

73. What
is
CMR
Answer posted by Mohan on 2005-05-21 17:14:47: CMR - Container Managed Relationships allows the
developer to declare various types of relationships between the entity beans
Comments: 1

Last Update: May 21, 2005 By Mohan

Answer

Added: May 21, 2005

74. What
is
the
difference
between
sessioncontext
and
entitycontext
Answer posted by Mohan on 2005-05-21 17:08:14: Session Context Contains information that a Session Bean
would require from the container Entity Context contains the information that an Entity Bean would require
from a container
Comments: 2

Last Update: May 21, 2005 By Mohan

Answer

Added: May 21, 2005

What is the difference between JNDI context, Initial context, session context and ejb
context
75.

Answer posted by Mohan on 2005-05-21 17:07:03: JNDI Context Provides a mechanism to lookup resources
on the network Initial Context constructor provides the initial context. Session Context has all the information a
session bean would require
Comments: 1

Last Update: May 21, 2005 By Mohan

Answer

Added: May 21, 2005

76. What
is
lazy
loading
Answered by Nikhil on 2005-05-11 11:28:14: Lazy loading is a characteristic of an application when the actual
loading and instantiation of a class is delayed until the point just before the instance is actually used. The goal
is to only dedicate memory
Comments: 2

Last Update: October 06, 2005 By Ashish

Gupta Answer

Added: May 11, 2005

77. What
is
the
life
cycle
of
MDB
Answered by Nikhil on 2005-05-11 01:52:59: The lifetime of an MDB instance is controlled by the container.
Only two states exist: Does not exist and Ready , as illustrated in the following figure:
The life of an MDB
instance starts
Comments: 1

Last Update: May 11, 2005 By Nikhil

Answer

Added: May 11, 2005

78. Is
stateless Sessiob bean create() method contains any parameters
Answered by Jey Ramasamy on 2005-05-08 20:04:33: No. This method must not contain any input
parameters and cannot be overloaded as well.
Added: May 08, 2005
Comments: 1 Last Update: May 08, 2005 By Jey Ramasamy Answer
79. What are the various transaction attributes and differences between them
Answered by Jey on 2005-05-08 18:01:39: There are six transaction attributes that are supported in EJB. 1.
NotSupported 2. Supports 3. Required 4. RequiresNew 5. Mandatory 6. Never
Comments: 1

Last Update: May 08, 2005 By Jey

Answer

Added: May 08, 2005

80. What
are
the
call
back
methods
in
Entity
bean
Answered by Jey Ramasamy on 2005-05-08 19:51:04: 1. setEntityContext() 2. ejbCreate() 3.
ejbPostCreate() 4. ejbActivate() 5. ejbPassivate() 6. ejbRemove() 7. unsetEntityContext()
81. What
is
deployment
descriptor
Answered by Jey on 2005-05-08 12:59:41: Deployment Descriptor is a XML document with .xml
extenion. It basically descripes the deployment settings of an application or module or the component.
At runtime J2EE server reads the deployment descriptor and
Added: May 08, 2005
Comments: 1 Last Update: May 08, 2005 By Jey Answer
82.

What is re-entrant. Is session beans reentrant. Is entity beans reentrant

Answered by Jey on 2005-05-08 12:09:49: Re-entrant means where Bean A calls methods of Bean B and then
Bean B turns around and calls methods of Bean A. The above all within a single thread of control. This is also
called as loopback. Entity
Comments: 1

Last Update: May 08, 2005 By Jey

Answer

Added: May 08, 2005

83. What
is
Message
Driven
Bean
Answered by Jey on 2005-05-08 12:30:37: Message Driven Bean (MDB) is an enterprise bean which runs
inside the EJB container and it acts as Listener for the JMS asynchronous message . It does not have Home
and Remote interface as Session or Entity bean.
Comments: 1

Last Update: May 08, 2005 By Jey

Answer

Added: May 08, 2005

84. What
is
the
difference
between
activation
and
passivation
Answered by Jey on 2005-05-08 11:55:29: Activation and Passivation is appilicable for only Stateful session
bean and Entity bean. When Bean instance is not used for a while by client then EJB Container removes it
from memory and puts it in
Comments: 1

Last Update: May 08, 2005 By Jey

Answer

Added: May 08, 2005

85. What
is
the
difference
between
EAR,
JAR
and
WAR
file
Answered by Jey on 2005-05-08 11:23:41: In J2EE application modules are packaged as EAR, JAR and WAR
based on their functionality JAR: EJB modules which contains enterprise java beans class files and EJB
deployment descriptor are packed as
Comments: 1

Last Update: May 08, 2005 By Jey

Answer

Added: May 08, 2005

86. What
is the difference between local interface and remote interface
We can describe the following common rules for choosing whether to use remote client view or local client
view: When you will potentially use a distributed environment (if your enterprise bean should be independent
of its deployment place)
Comments: 1

Last Update: October 23, 2005 By John

Answer

Added: May 03, 2005

87. What
is
the
lifecycle
of
Entity
Bean
The following steps describe the life cycle of an entity bean instance An entity bean instances life starts when
the container creates the instance using newInstance and then initialises it using setEntityContext. The
instance enters
Comments: 1

Last Update: April 29, 2005 By Raveendra Ponnam

Answer

Added: April 29, 2005

88. Why an onMessage call in Message-driven bean is always a seperate transaction


The MDB is stateless and inherently each message is unique with respect to the MDB. Each message needs
to be processed independently. Hence the need for separate transactions
Added: April 26, 2005
Comments: 1 Last Update: April 26, 2005 By Anand Answer
89. What
is
EJB
architecture(components)
EJB Architecture consists of : a) EJB Server b) EJB containers that run on these servers, c) Home Objects,
Remote EJB Objects and Enterprise Beans that run within these containers, d) EJB Clients and e) Auxillary
systems
Added: April 17, 2005
Comments: 1 Last Update: April 17, 2005 By Lavanya Answer
90. Is it possible to invoke multiple Session beans from one Session bean using Reflection
You use reflection when you actually instantiate the objects or invoke the method.In the EJB Scenario Beans
invoke other Beans as clients. The client only looks up the objects (not instantiating) and the operations are
invoked on the stubs only.InitialContext
91. Is it possible to share an HttpSession between a JSP and EJB. What happens when I change a
value
in
the
HttpSession
from
inside
an
EJB
You can pass the HttpSession as parameter to an EJB method, only if all objects in session are

serializable. This has to be consider as "passed-by-value", that means that it's read-only in the EJB. If
anything is altered from inside the EJB, it won't
Comments: 1 Last Update: November 07, 2005 By RajaSekhar Reddy Added: August 26,
2004
t Answer

How can i retrieve from inside my Bean(Stateless session and Entity CMP) the user
name which i am serving (the user name of user just logged in my web application)
92.

Inside an EJB you may retrieve the "Caller" name, that is the login id by invoking:
sessionContext.getCallerIdentity().getName() where sessionContext is the instance of "SessionContext"
(setSessionContext) passed to the Session Bean, or the instance of
Added: August 26,
Comments: 0
Answer
2004

If my session bean with single method insert record into 2 entity beans, how can I know
that the process is done in same transaction (the attributes for these beans are Required)
93.

If your method in the session bean is already running under a transaction the calls to any other bean which
have been deployed with trans-attribute 'Required' will be executed within the same transaction context. So if
your session bean is using container-managed
Added: August 26,
Comments: 0
Answer
2004

Is there a way to get the original exception object from inside a nested or wrapped
Exception
(for
example
an
EJBException
or
RemoteException)
94.

Absolutely yes, but the way to do that depends on the Exception, since there are no standards for that. Some
examples: When you have an javax.ejb.EJBException, you can use the getCausedByException() that returns
a java.lang.Exception. A java.rmi.RemoteException
1. How can i restrict the user from Clicking of Back button in anybrowser
What is meta tag?and where should i write the mentioned code.Pankaj
Added: November 04,
Comments: 2 Last Update: November 12, 2005 By Pankaj Answer
2005

in one class i stored the key and values in the hashmap.so using key value i have to
check wheterthe value for key is correct or not.so howto retreive the key and values in jsp
page
2.

in one class i stored the key and values in the hashmap.so using key value i have to check wheterthe value for
key is correct or not.so howto retreive the key and values in jsp page
Added: October 26,
Comments: 2 Last Update: November 13, 2005 By chandramohan Answer 2005
3. What
is the differnce between application server and web server
application server can handle any type of protocal,but other handles only http protocal
Added: October 26,
Comments: 4 Last Update: November 13, 2005 By santanu Answer
2005
4. what is use of implict Objects?why the container is given those one?
In JSP, there is no need to create object explicitly to get the request ,to post the response and to display the
result.Objects like request,response,page and out are created by the JSP Engine implicitly.It reduces the
coding and also saves memor
Added: October 26,
Comments: 2 Last Update: November 03, 2005 By Tharani Answer
2005
5. How
to
delete
cookies
in
JSP?
As the above answer mentioned, but the setMaxTime should be setMaxAge, setMaxTime doesn't exist.
Added: October 24,
Comments: 3 Last Update: October 31, 2005 By Richard Answer

2005

In Oracle table some fields are "null".By default it will show as "null" in JSP page text
box.But i dont want that. I want as blank textbox.What i can do for that?
6.

Well for that, u need to write a small code segment which will check for the Null value and if NULL value is
found then a space will be inserted in the respective Text Box else the value.
Added: October 23,
Comments: 3 Last Update: November 03, 2005 By Amitava Pal Answer 2005
7. In Internet explorer if we give a jsp , How the server will know it has to execute?
Whenever we type any thing in Internet Explorer it make a query with the Server that with which program JSP
extension is associated.After querying the Registery of Server/Machine, In result it is executed with the
associated program.For example whenever
Added: October 20,
Comments: 1 Last Update: November 02, 2005 By Nitin Gautam Answer
2005
8. How the jsp changes will be effected in servlet file after converting?
Here jsp engine cheack whether jsp page is older than its servlet page or not and on the basis of this it it's
decide whether changes are needed or not.
Comments: 2 Last Update: November 03, 2005 By Mannu Kumar Added: October 20,
2005
Pandey Answer

when to use struts technology? what type of applications are developed using struts
frame
work?
9.

for large applications and repeated view can be happen from different actions mainly struts technology is used
for easily maintian large applications compare with jsp technology and more....
Added: October 18,
Comments: 1 Last Update: November 07, 2005 By charan Answer
2005
10. what
is
the
need
of
taglibraries?
answer the question.....
11. explain online banking system using java.that means i need architecture of online banking
system.please
sir
i
want
full
details
Here we used mainly HTML form and jsp page with seesion management, jdbc etc.
Comments: 1 Last Update: November 03, 2005 By Mannu Kumar Added: October 15,
2005
Pandey Answer

text in textarea cant be copy by anyone while it is running in the browser (i.e,the text
cant be copy and then paste on the other page) give me suggestion?
12.

Comments: 0

Answer

Added:
2005

October

13,

how can i clear values in sessions.if i open a jsp page it is containing previous
values.then i need to open a new page then only i am getting a fresh page
13.

one solution is use session.invalidate() to clear the sessionor session.removeAttribute("Object Name") to


unbound an Object from session
Added: October 13,
Comments: 2 Last Update: November 04, 2005 By sudhakar Answer
2005

what data is stored in the variable appname when we give the folowing statement String
appname=("manager".equalsIgnoreCAse(request.getContextPath()))?"/manager":"/portal";
14.

Comments: 0

Answer

Added:

October

07,

2005
15.

web browser concept using jsp

Comments: 0

Added:
2005

Answer

October

05,

16. Why we can't implement interface in JSP?Why we can only extend classes in JSP?
Implementing an interface means providing a specific behavior to your class. Since jsp are to be interpreted by
servlet-container and will then be executed as a servlet, it cant be used for that extended behavior. Thus no
use of implementing it.Sandeep
Added: October 03,
Comments: 1 Last Update: October 19, 2005 By Sandeep Jindal Answer
2005

How can we implement logoutpage using jsp ..?and Is there any method to force the
browser to show the same page again and again after logout..?
17.

session.invalidate();put the above method that session is expire then u design as per the client requirement
Added: October 03,
Comments: 1 Last Update: October 03, 2005 By sarat Answer
2005
18. How
to
Upload
a
textfile
from
JSP
to
Servlet
if u used MVC architecture u just usedin jsp<input type="file" > tagand in servlet use just used servletInput
stream to get that fileand do whatever u want by using IO.api package
Added: October 03,
Comments: 1 Last Update: October 20, 2005 By charanvv Answer
2005
19.

How to upload a textfile from JSP to Servlet

Comments: 0

Added:
2005

Answer

October

03,

My html form contains an INPUT "text" element that accepts Date, i want to catch that
date and want to query it using JSP?In short, how can i use that HTML form element with
Prepared Statements in JSP?
20.

21. Types of indexing used in oracle applications ?andwhen and how we decide to implement indexing
to database ?
Added: September 29,
Comments: 0
Answer
2005
22. please
write
question
if you have given any in interglobe technologies
Comments: 0

of

interglobe

Added: September 28,


2005

Answer

23. What
is
the
need
of
They are used to manipulate the requests, responses and sessions
Comments: 1

Last Update: October 08, 2005 By ravneet

Answer

24. what
is
datacatching
it can store in catch and move one page to another page
Comments: 0
25.

Answer

technologies

implicit

objects?

Added: September 27,


2005

in

jsp

Added: September 24,


2005

when we design some login form how we manage security for those forms?which

technology

used

for

that

purpose?

use session tracking concepts. so that it ensure only authenticated users are allowed to access the page.
Added: September 20,
Comments: 1 Last Update: November 04, 2005 By Suresh Answer
2005
26. How
Do
you
implement
jsp doesn't allow implementing interfaces.it supports only extends.
Comments: 1

Last Update: November 04, 2005 By Suresh

interface

interface

Comments: 1

Answer

JSP?

Added: September 19,


2005

Answer

27. How
can
initialize
We can not initialize the interface in a JSP
Last Update: September 23, 2005 By Raghu

in

in

JSP?

Added: September 19,


2005

28. How
do
u
maintain
a
Session?
Ans- A session can be created via the getSession () method of HttpServletRequest. An HttpSession object is
returned. This object can store set bindings that associated names with objects. This setAttribute (),
getAttribute (), getAttributeNames (), and
Added: September 17,
Comments: 0
Answer
2005
29.

what is the differences between JSP LifeCycle and Servlet LifeCycle?

Comments: 0

Answer

30. Can
Pls comment
31. What
Pata Nahin

Comments: 6

is

Added: September 16,


2005

call
the

Difference

an

interface
between

in

sendRedirect()

Last Update: November 08, 2005 By Prakash

JSP?

and

Forward?

Added: September 14,


2005

Answer

I want to place two buttons one for save and one for delete.i am using DispatchAction
as controller,how can i find which button i am pressing and how to diffrentiate?
32.

DispatchAction
Comments: 1

Last Update: November 03, 2005 By

Mannu Kumar

Pandey Answer

Added: September 12,


2005

33. What
is
JSP
Jsp is content generator.Using the scripting tags it generates content. when the jsp engine(jsp
container) loads the jsp the code for the servlet automatically generated to convet jsp into servlet.This is
translation time. &nbs
Added: September 10,
Comments: 18 Last Update: October 26, 2005 By Ashwini Answer
2005
34. What
is the difference betweeen a statis and dynamic include?
static means server will not execute that part and send it to client as it is while dynamic contect will be
executed by server and then its resultant will send to client
Comments: 2

Last Update: November 03, 2005 By

Mannu Kumar

Pandey Answer
35.

What

are

advantages

Added: September 07,


2005

of

JSP

Easily saying1)Auto compilation(translation.....)2)Not deployment descritpor specific3)Multiple deployment is


avoided.
Added: September 06,
Comments: 8 Last Update: October 08, 2005 By tariqj2ee Answer
2005
36. How
can
my
JSP
communicate
we can create java class file and call the package in jsp
Comments: 5

Last Update: September 06, 2005 By senthil

with

java

Answer

class

file

Added: September 06,


2005

I want to accomplish the following scenario:1) user submits a jpg/gif file from an html
form (using <input type="file"> in the form, the user can browse to a file of their choice)2)
upload the jpg/gif file through a combination of Java and JSP's3) put the jpg/gif into a
database on a server and/or into a folder on my local system.
37.

Comments: 0
38.

how to upload an image from a localserver into a jsp page

Comments: 0
39.

Added: September 05,


2005

Answer

Added: September 05,


2005

Answer

How to pop up a jsp page?refreshing every two seconds.

Comments: 0

Added: September 03,


2005

Answer

How to use eba grid in jsp page?


Comments: 0
Answer
41. What
40.

is

Declaration

A Declaration is a block of Java code in a JSP that is used to define class-wide variables and methods in
the generated class file.
They are initialized when the JSP
Comments: 5

Last Update: September 30, 2005 By

AHMAD Answer

MD SHAKEEL

Added:
2005

August

26,

42. What
is
difference
between
scriptlet
and
expression
An Expression tag opens with <%= and ends with %>Scriptlet tag opens with <% and ends with %>ex:<%! int
a=10,b=5,res=0;%><%res=a+b;out.print("Result is "+res); %><html><body><p>The Result is <%=a+b
%></p></body></html>An
Added: August 26,
Comments: 5 Last Update: October 01, 2005 By madhavi Answer
2005
43. What is the difference between include directive & jsp:include action
The include directive inserts the source at translation time whereas the include standard action inserts the
response of the included file at runtime.
Added: August 23,
Comments: 17 Last Update: October 24, 2005 By sandy Answer
2005
44. How
do
you
call
stored
procedures
from
JSP
sasi Wrote:Hai u can bean like a simple java prg.and compile it to create the class file.then using the
jsp:useBean attribute u can connect the Bean.
Added: August 15,
Comments: 7 Last Update: October 05, 2005 By vadivel Answer
2005

45. What does < %= obj.getXXX() %> the following expression get evaluated to ?
This expression gets evaluated to an argument for the println statement in the generated Servlet as
follows:out.println( obj.getXXX() ); // Since it becomes an argument here you should not use semicolon in the
JSP expression
Added: August 13,
Comments: 0
Answer
2005
46. How can we move from one JSP page to another(mean using what tecnique?)
A Jsp can either "redirect "or "dispatch " to another JSP. // use this if you just want to invoke another
//JSP response.sendRedirect("Jsp URL"); // use this if you want to pass info from one // jsp to another
Added: August 12,
Comments: 2 Last Update: August 11, 2005 By PChal Answer
2005
47. Can
we
implements
interface
or
extends
class
in
JSP?
You cannot extend any class in JSP because a JSP has no value to it on its own. It will only be useful when
converted to a servlet and every servlet has to extend HTTPServlet. In this case HttpJspBase According to
Java Language spec a class
Added: August 12,
Comments: 4 Last Update: August 11, 2005 By Pchal Answer
2005
48. How do you prevent the Creation of a Session in a JSP Page and why?
By default, a JSP page will automatically create a session for the request if one does not exist. However,
sessions consume resources and if it is not necessary to maintain a session, one should not be created. For
example, a marketing campaign may suggest
Added: August 12,
Comments: 2 Last Update: September 12, 2005 By Praveen Answer
2005
49. How
do
you
restrict
page
errors
display
in
the
JSP page
hi, We Can restrict page errors by using the two attributes of page directive i.e. error attribute set to true and
then use the errorPage attributes that specifies the url of Error page.Thanks
Added: August 11,
Comments: 6 Last Update: September 14, 2005 By Nisar Khatib Answer
2005

How can you include a static file in JSP page. is it possible in html style sheet. which
one is better jsp's include directive ("<%@include="filename"%>) or html's style sheet.
50.

51. How
do
you
using JDBC-ODBC connection
Comments: 5

to

Last Update: October 15, 2005 By swapna

52. How can we move from


<jsp:forward page="/pagename" /
Comments: 1

connect

the

Answer

database

from

JSP

Added: July 31, 2005

one JSP page to another(mean using what tecnique?)

Last Update: November 09, 2005 By Deep

Answer

Added: July 30, 2005

53. How
do
you
pass
control
from
one
JSP
page
to
another
prasadraju Wrote: we can forward control to aother jsp using jsp action tags forward or incllude You are right
in saying that JSP action tag <jsp:forward page="relativeURL" /> could be used to forward control from one jsp
to another jsp
Added: July 28, 2005
Comments: 5 Last Update: September 27, 2005 By Raja Rao Answer

What is jsp:usebean. What are the scope attributes & difference between these
attributes
54.

Using a Bean in a JSP PageTo use a bean in a JSP page, three attributes must be supplied - an id, which
provides a local name for the bean, the bean's class name, which is used to instantiate the bean if it does not
exit, and a scope, which specifies

Comments: 5

Last Update: October 14, 2005 By satyagodey

Answer

Added: July 27, 2005

55. What
are the steps required in adding a JSP Tag Libraries?
1. Create a TLD file and configure the required class Information.2. Create the Java Implementation Source
extending the JSP Tag Lib Class (TagSupport).3. Compile and package it as loosed class file or as a jar under
lib folder in Web Archive File
Added: July 16, 2005
Comments: 0
Answer
56. What
are the implicit objects in JSP & differences between them
There are nine implicit objects in JSP. 1. pageContext 2. session 3. request 4. response 5. exception 6. out 7.
application 8. config 9. page These are used for different purposes and actually
Comments: 1

Last Update: May 31, 2005 By Santhosh

Answer

Added: May 31, 2005

57. What are Custom tags. Why do you need Custom tags. How do you create Custom tag
Custom tags are User defined tags.The main reason to need custom tags is To eliminate the java code in
Jsp's.i.e in case of java code we simple inser the custom tags.Exapmle:Data base Connection etc.....
Added: May 26, 2005
Comments: 2 Last Update: October 03, 2005 By Chinna Answer
58. Can I stop JSP execution while in the midst of processing a request?
Yes. Preemptive termination of request processing on an error condition is a good way to maximize the
throughput of a high-volume JSP engine. The trick (asuming Java is your scripting language) is to use the
return statement when you want to terminate
Added: March
25,
Comments: 1 Last Update: March 25, 2005 By suneel reddy Answer
2005
59. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
60. What
are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
61. What
is
the
difference
between
ServletContext
and
ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass
configuration information to a servlet. The server passes an object that implements the ServletConfig
interface to the servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
62. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
63. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
64.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

65. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August 28,
Comments: 0
Answer
2004
66. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
2004

August

28,

67. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
68. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
69. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
70.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Comments: 0

Answer

71. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
72. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.

Thus servlets can be used to balance


Comments: 0

Answer

Added:
2004

August

28,

73. What
are
the
advantages
using
servlets
than
using
CGI?
Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. It is
efficient, convenient, powerful, portable, secure and inexpensive. Servlets also address the problem of doing
server-side programming with platform-specific
Added: August 28,
Comments: 0
Answer
2004
74.
Comments: 0

Answer

Added:
2004

August

28,

75. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
76. What
are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
77. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
78. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
79. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
80.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer
is

81. What
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only

when they shut down)


Comments: 0

Added:
2004

Answer

82. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

28,

use the PrintWriter?


Added:
2004

Answer

August

August

28,

83. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
84. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
85. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
86.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
87. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
88. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
89.
a

Difference

Comments: 0

between
Answer

single

thread

and

multi

thread

model

Added:
2004

servlet
August

28,

90. What
are
the
advantages
using
servlets
than
using
CGI?
Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. It is
efficient, convenient, powerful, portable, secure and inexpensive. Servlets also address the problem of doing
server-side programming with platform-specific
Comments: 0

Answer
is
the
difference

91. What
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
92. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
93. What
are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
94. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
95. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
96. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
97.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

98. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)

Comments: 0

Added:
2004

Answer

99. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

28,

use the PrintWriter?


Added:
2004

Answer

August

August

28,

100. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.

Answer
When a servlet accepts a call from a client, it receives two objects. What are they?

Comments: 0

101.
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
102. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
103.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
104. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
105. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
106. Difference
between single
whatis the exact answer of this question
Comments: 1

thread

and

multi

Last Update: October 20, 2005 By Ranveer Kumar

thread

Answer

model

Added:
2004

servlet
August

28,

107. What
are
the
advantages
using
servlets
than
using
CGI?
Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. It is
efficient, convenient, powerful, portable, secure and inexpensive. Servlets also address the problem of doing

server-side programming with platform-specific


Comments: 0

Answer

Added:
2004

August

28,

108. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
109. What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
110. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Comments: 0

Answer
I
invoke

111. Can
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
112. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
113.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

114. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August 28,
Comments: 0
Answer
2004
115. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
2004

August

28,

116. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard

HTTP client requests by dispatching each request to a method designed to handle that request.
Added:
Comments: 0
Answer
2004

August

28,

117. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
118. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
119.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
120. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Comments: 0

Answer
are

121. What
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
122.

Difference between single thread and multi thread model servlet

Comments: 0

Answer

Added:
2004

August

28,

123. What
are
the
advantages
using
servlets
than
using
CGI?
Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. It is
efficient, convenient, powerful, portable, secure and inexpensive. Servlets also address the problem of doing
server-side programming with platform-specific
Added: August 28,
Comments: 0
Answer
2004
124. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004

125. What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
126. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
127. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
128. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
129.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

130. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)

Answer
Which code line must be set before any of the lines that use the PrintWriter?

Comments: 0

131.
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

Added:
2004

August

28,

132. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
133. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004

134. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
135.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
136. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
137. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
138.

Difference between single thread and multi thread model servlet

Comments: 0

Answer

Added:
2004

August

28,

Answer

Added:
2004

August

28,

139.
Comments: 0

140. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Comments: 0

Answer
are the differences

141. What
between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
142. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004

143. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
144. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
145.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

146. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August 28,
Comments: 0
Answer
2004
147. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
2004

August

28,

148. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
149.

Difference between single thread and multi thread model servlet

Comments: 0

Answer

Added:
2004

August

28,

150. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet

Answer
What information that the ServletRequest interface allows the servlet access to?

Comments: 0

151.
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
152.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
153. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
154. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
155. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August 28,
Comments: 0
Answer
2004
156. What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
157. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
158. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
159. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
160.

Simply have doGet call doPost, or vice versa.

Comments: 0

Answer

161. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August 28,
Comments: 0
Answer
2004
162. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

use the PrintWriter?


Added:
2004

Answer

August

28,

163. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
164. Difference
between single thread and multi thread model servlet
In single thread model the sevelet will implement SingleThreadMidel interface means only one client can
access the servlet.Because of this the response time is very slow.In Multithread model the creates pool os
servlet instances and manages the servlet
Added: August 28,
Comments: 1 Last Update: October 03, 2005 By Prasad Answer
2004
165. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
166. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August 28,
Comments: 0
Answer
2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
167.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August 28,
Comments: 0
Answer
2004
168. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August 28,
Comments: 0
Answer
2004
169.

What

are

the

uses

of

Servlets?

A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August 28,
Comments: 0
Answer
2004
170. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Comments: 0

Answer
are the differences

171. What
between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August 28,
Comments: 0
Answer
2004
172. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August 28,
Comments: 0
Answer
2004
173. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August 28,
Comments: 0
Answer
2004
174. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August 28,
Comments: 0
Answer
2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
175.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
2004

August

28,

176. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August 28,
Comments: 0
Answer
2004
177. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
2004

August

28,

178. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August 28,
Comments: 0
Answer
2004
179.

Difference between single thread and multi thread model servlet

Comments: 0

Answer

Added:
2004

August

28,

180. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet
Added: August 28,
Comments: 0
Answer
2004
181. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August
Comments: 0
Answer
28, 2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
182.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August
Comments: 0
Answer
28, 2004
183. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August
Comments: 0
Answer
28, 2004
184. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August
Comments: 0
Answer
28, 2004
185. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Added: August
Comments: 0
Answer
28, 2004
186. What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can

send back using a GET is restricted


Comments: 0

Answer

Added:
28, 2004

August

187. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August
Comments: 0
Answer
28, 2004
188. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.
Added: August
Comments: 0
Answer
28, 2004
189. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August
Comments: 0
Answer
28, 2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
190.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer
is

191. What
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August
Comments: 0
Answer
28, 2004
192. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
28, 2004

August

193. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August
Comments: 0
Answer
28, 2004
194. Difference
between single thread and multi thread model servlet
if we are implementing singlethreadmodel then at a time one request is serviced & every time a new reqyest is
coming so new instance is created.if we are implementing multithreadmodel then at a time more than one
request is serviced so every time a new
Added: August
Comments: 1 Last Update: September 14, 2005 By Anant Answer
28, 2004
195. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are

interfaces defined by the javax.servlet


Comments: 0

Answer

Added:
28, 2004

August

196. What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August
Comments: 0
Answer
28, 2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
197.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.
Added: August
Comments: 0
Answer
28, 2004
198. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August
Comments: 0
Answer
28, 2004
199. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August
Comments: 1 Last Update: September 15, 2005 By komal Answer
28, 2004
200. What
is
the
difference
between
GenericServlet
and
HttpServlet?
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is
implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a
client request is made. This means that it
Comments: 0

Answer
are the differences

201. What
between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of
the data to the URL and it will show up in the URL bar of your browser. The amount of information you can
send back using a GET is restricted
Added: August
Comments: 1 Last Update: September 16, 2005 By Praveen Answer
28, 2004
202. What
is the difference between ServletContext and ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to pass configuration
information to a servlet. The server passes an object that implements the ServletConfig interface to the
servlet's init() method.The ServletContext
Added: August
Comments: 1 Last Update: September 12, 2005 By Praveen Answer
28, 2004
203. Can
I
invoke
a
JSP
error
page
from
a
servlet?
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to
create a request dispatcher for the JSP error page, and pass the exception object as a
javax.servlet.jsp.jspException request attribute.

Comments: 0

Answer

Added:
28, 2004

August

204. Can
I
just
abort
processing
a
JSP?
Yes. Because your JSP is just a servlet method, you can just put (whereever necessary) a < % return; % >
Added: August
Comments: 0
Answer
28, 2004

If you want a servlet to take the same action for both GET and POST request, what
should
you
do?
205.

Simply have doGet call doPost, or vice versa.


Comments: 0

Answer

Added:
28, 2004

August

206. What
is
the
servlet
life
cycle?
Each servlet has the same life cycle:A server loads and initializes the servlet (init())The servlet handles zero or
more client requests (service())The server removes the servlet (destroy()) (some servers do this step only
when they shut down)
Added: August
Comments: 0
Answer
28, 2004
207. Which code line must be set before any of the lines that
setContentType() method must be set before transmitting the actual document.
Comments: 0

Answer

use the PrintWriter?


Added:
28, 2004

August

208. How
HTTP
Servlet
handles
client
requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard
HTTP client requests by dispatching each request to a method designed to handle that request.
Added: August
Comments: 0
Answer
28, 2004
209. Difference
between single thread and multi thread model servlet
the single thread model can cater to only one client at a time and puts the other clients requesting in the queue
whereas the multi thread model caters to as many clients requesting as possible.
Added: August
Comments: 1 Last Update: September 15, 2005 By ankit sharma Answer
28, 2004
210. When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which
encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse are
interfaces defined by the javax.servlet

Answer
What information that the ServletRequest interface allows the servlet access to?

Comments: 0

211.
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by
the client, and the names of the remote host that made the request and the server that received it. The input
stream, ServletInputStream.Servlets
Added: August
Comments: 0
Answer
28, 2004

What information that the ServletResponse interface gives the servlet methods for
replying
to
the
client?
212.

It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream,
ServletOutputStream and a Writer through which the servlet can send the reply data.

Comments: 0

Answer

Added:
28, 2004

August

213. What
is
the
servlet?
Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For
example, a servlet may be responsible for taking data in an HTML order-entry form and applying the business
logic used to update a company's order
Added: August
Comments: 0
Answer
28, 2004
214. What
are
the
uses
of
Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to
support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance
Added: August
Comments: 0
Answer
28, 2004

How do I have the JSP-generated servlet subclass my own custom servlet class,
instead
of
the
default?
215.

One should be very careful when having JSP pages extend custom servlet classes as opposed to the default
one generated by the JSP engine. In doing so, you may lose out on any advanced optimization that may be
provided by the JSPengine. In any case, your
Added: August
Comments: 0
Answer
28, 2004
216. How
does
a
servlet
communicate
with
a
JSP
page?
The following code snippet shows how a servlet instantiates a bean and initializes it with FORM data posted by
a browser. The bean is then placed into the request, and the call is then forwarded to the JSP page, Bean1.jsp,
by means of a request dispatcher
Added: August
Comments: 0
Answer
28, 2004
217. Is there a way I can set the inactivity lease period on a per-session basis?
Typically, a default inactivity lease period for all sessions is set within your JSPengine admin screen or
associated properties file. However, if your JSP engine supports the Servlet 2.1 API, you can manage the
inactivity lease period on a per-session
Added: August
Comments: 0
Answer
28, 2004
218. How can I set a cookie and delete a cookie from within a JSP page?
A cookie, mycookie, can be deleted using the following scriptlet:<%//creating a cookieCookie mycookie = new
Cookie("aName","aValue");response.addCookie(mycookie);//delete a cookieCookie killMyCookie = new
Cookie("mycookie",
null);killMyCookie.setMaxAge(0);killMyCookie.setPath("/");response.addCookie(killMyCookie);%&g
Added: August
Comments: 0
Answer
28, 2004
219. How
can
I
declare
methods
within
my
JSP
page?
You can declare methods for use within your JSP page as declarations. The methods can then be invoked
within any other methods you declare, or within JSP scriptlets and expressions.Do note that you do not have
direct access to any of the JSP implicit
Added: August
Comments: 0
Answer
28, 2004
220. How can I enable session tracking for JSP pages if the browser has disabled cookies?
We know that session tracking uses cookies by default to associate a session identifier with a unique user. If

the browser does not support cookies, or if cookies are disabled, you can still enable session tracking using
URL rewriting. URL rewriting essentially
Comments: 0

Answer
do I use

221. How
a scriptlet to initialize a newly instantiated bean?
A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically
invoked when the specified bean is instantiated. Typically, the body will contain scriptlets or jsp:setProperty
tags to initialize the newly
Added: August
Comments: 0
Answer
28, 2004
222. How
does
JSP
handle
run-time
exceptions?
You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically
forwarded to an error processing page. For example:<%@ page errorPage="error.jsp" %>redirects the
browser to the JSP page error.jsp if an
Added: August
Comments: 0
Answer
28, 2004

How do I prevent the output of my JSP or Servlet pages from being cached by the
browser?
223.

You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP
page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP
pages to prevent them from being cached
Added: August
Comments: 0
Answer
28, 2004
224. How
do
I
use
comments
within
a
JSP
page?
You can use "JSP-style" comments to selectively block out code while debugging or simply to comment your
scriptlets. JSP comments are not visible at the client.For example:<%-- the scriptlet is now commented out<
%out.println("Hello World");%>--%>You
Added: August
Comments: 0
Answer
28, 2004
225. Is there a way to reference the "this" variable within a JSP page?
Yes, there is. Under JSP 1.0, the page implicit object is equivalent to "this", and returns a reference to the
servlet generated by the JSP page.
Added: August
Comments: 0
Answer
28, 2004
226. How
do
I
perform
browser
redirection
from
a
JSP
page?
You can use the response implicit object to redirect the browser to a different resource,
as:response.sendRedirect("http://www.exforsys.com/path/error.html");You can also physically alter the
Location
HTTP
header
attribute,
as
shown
below:<
%response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);String
Added: August
Comments: 0
Answer
28, 2004
227. How
do
I
include
static
files
within
a
JSP
page?
Answer Static resources should always be included using the JSP include directive. This way, the inclusion is
performed just once during the translation phase. The following example shows the syntax:<%@ include
file="copyright.html" %>Do note that
Added: August
Comments: 0
Answer
28, 2004
228. What
JSP
lifecycle
methods
can
I
override?
You cannot override the _jspService() method within a JSP page. You can however, override the jspInit() and

jspDestroy() methods within a JSP page. jspInit() can be useful for allocating resources like database
connections, network connections, and so
Added: August
Comments: 0
Answer
28, 2004
229. Can
a
JSP
page
process
HTML
FORM
data?
Yes. However, unlike servlets, you are not required to implement HTTP-protocol specific methods like doGet()
or doPost() within your JSP page. You can obtain the data for the FORM input elements via the request implicit
object within a scriptlet or expression
Added: August
Comments: 0
Answer
28, 2004
230. How
do
I
mix
JSP
and
SSI
#include?
If you're just including raw HTML, use the #include directive as usual inside your .jsp file.<!--#include
file="data.inc"-->But it's a little trickier if you want the server to evaluate any JSP code that's inside the included
file. If your data.inc
231. How
can
I
implement
a
thread-safe
JSP
page?
You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This
is done by adding the directive <%@ page isThreadSafe="false" % > within your JSP page.
Added: August
Comments: 0
Answer
28, 2004
232. How
do
I
include
static
files
within
a
JSP
page?
Static resources should always be included using the JSP include directive. This way, the inclusion is
performed just once during the translation phase. The following example shows the syntax: Do note that you
should always supply a relative URL for the
Added: August
Comments: 0
Answer
28, 2004
233. How
do
I
include
static
files
within
a
JSP
page?
Static resources should always be included using the JSP include directive. This way, the inclusion is
performed just once during the translation phase. The following example shows the syntax: Do note that you
should always supply a relative URL for the
Added: August
Comments: 0
Answer
28, 2004

What is the page directive is used to prevent a JSP page from automatically creating a
session:
234.

<%@ page session="false">


Comments: 0

Answer

Added:
28, 2004

August

Is it possible to share an HttpSession between a JSP and EJB? What happens when I
change
a
value
in
the
HttpSession
from
inside
an
EJB?
235.

You can pass the HttpSession as parameter to an EJB method, only if all objects in session are
serializable.This has to be consider as "passed-by-value", that means that it's read-only in the EJB. If anything
is altered from inside the EJB, it won't be
Added: August
Comments: 0
Answer
28, 2004
236. Can
a
JSP
page
instantiate
a
serialized
bean?
No problem! The useBean action specifies the beanName attribute, which can be used for indicating a
serialized
bean.
For
example:<jsp:useBean
id="shop"
type="shopping.CD"
beanName="CD"
/><jsp:getProperty name="shop" property="album" />A couple
Added: August
Comments: 0
Answer
28, 2004

237. Can you make use of a ServletOutputStream object from within a JSP page?
No. You are supposed to make use of only a JSPWriter object (given to you in the form of the implicit object
out) for replying to clients. A JSPWriter can be viewed as a buffered version of the stream object returned by
response.getWriter(), although

Answer
you

Comments: 0

1. Have
Yes ,single thread module
Comments: 3

threads

Last Update: November 14, 2005 By veeru

2. waht
is the
give me the answer
Comments: 6

used

difference

between

in

Added: November 12,


2005

Answer

Generic

Servelet

servlet

Last Update: November 12, 2005 By veerendra nadh

and

HTTPServlet
Added:
November
2005

Answer

10,

how do to prevent user by viewing secured page by clicking back button when session
expired..:)
3.

You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP
page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP
pages to prevent them from being cached
Added: November 09,
Comments: 1 Last Update: November 10, 2005 By Arindam Answer
2005
4. how
do we prevent user to read secured page..
Programatically invalidate the session by calling the method session.invalidate()
Comments: 1

Last Update: November 11, 2005 By Hari

after

logout

Added:
November
2005

Answer

09,

5. What is default Session time out in the servers like Tomcat, Weblogic, JBoss,..etc?
The default time for session time out is 30 minutes...but these can be overwritten programmatically using the
setSessionInActiveInterval() function
Comments:

Last

Update:

November

6. What
is
difault
the default http method is Get

http

08,

2005

By

Anoop

Kavalloor Answer

Comments: 1

method

Last Update: November 08, 2005 By sudhir

Answer

in

Added: November 07,


2005

http

servlet?

Added:
November
2005

05,

how can a servlet automatically updated by its data without refreshing?take one example
of one sensex site. the corresponding data are shown in a scrolling manner. how they can
automatically be refreshed after some time. without refreshing the page.
7.

hiThe web page can be refreshed automatically by using this method in your codesetHeader("refresh","<amt of
time>");
Added: November 04,
Comments: 1 Last Update: November 11, 2005 By sudhakar Answer
2005
8. what
is
send
redirect
method?
and
when
it
is
used?
send redirect method is to send the control to a new page(URL) from the current working web page.this is

done when the browser wants the user to send the control to another page when some event is performed.
Added:
November
03,
Comments: 3 Last Update: November 05, 2005 By Kavita Answer
2005

in servlets, what is the use of sendredirect(),include( ), forward() ?and in applecation


level
at
what
scnario
they
will
be
used
9.

i know only that send redircet is of client side. and remaing are severside functions
Comments: 3

Last Update: November 10, 2005 By ss

Answer

Added:
2005

October

26,

10. how
to get initialization time (init () method)values in servlet?
servletconfig is a wrapper class object which can be used to retrive initilise parameters from web.xml file and
wrappes into servlet instance.in this way sevlet constructor is dynamically initilised.plz send me comments on
answer &nbs
11. how to get value from init() method in servlet? orhow to get initializaion time values from init() in
servlet?
plz ans !!!!!!!!!!!!!!!!!!!
Added:
October 21,
Comments: 10 Last Update: November 11, 2005 By shuaib Answer
2005
12. How we can check in particular page the session will be alive or not?
U can use request.getSession(false); method in HttpServletRequest interface.It returns the HttpSession
associated with this request or null if the request has no valid session.
Added: October
Comments: 3 Last Update: October 20, 2005 By Kavitha Answer
14, 2005
13. in
which
conditions
we
have
to
use
the
ServletContext
To get RequestDispatcher object.Not only this but there are several other conditions too to Use
ServletContext
Comments:
5 Last
Update:
November
09,
2005
By Added:
October 11,
BhupenderDonGiri Answer
2005

suppose in web.xml file we are given 30 and in the servlet program we are given
setSessionInActiveInterval(40).when that session will be terminated ? After 30 sec or
40
sec?
14.

session will be terminated depending upon the later updation means it depend upon the xml file and it
will take 40 sec because after compiling it will update xml file into 40 sec
Added: October
Comments: 1 Last Update: October 21, 2005 By amit Answer
10, 2005
15. how much amount of information will be stored within a session
In a session wee can store large amount of data as much as possible. Initially session is used to store
information by the client while transaction is made.
Added:
October 10,
Comments: 2 Last Update: November 06, 2005 By saravanaraj Answer
2005
16. what
are
the
JSP
atrributes?
there are three directives are used in the jsp. one of them is page directive. and the page directive have
11 attributes, which is used to give the information about that page. the 11 attributes are following:language, buffer, isThreadSafe, setContentType

Comments: 1

Last Update: November 12, 2005 By dharam

Answer

Added: October
05, 2005

i want to know how to encode textbox in servlet so we find complete column


information
from
the
database
17.

plese help me
Comments: 2

Last Update: November 02, 2005 By Alex

18. Types
HttpServletand Generic Servlet
Comments: 3

Answer

of

Last Update: November 03, 2005 By saf

Added:
September
30, 2005

Servlets?
Answer

Added:
September
2005

29,

19. What
is
the
super
class
of
All
servlets?
servlet super class is the Servlet only.but it is the servlet technology by the javasoft people already
defined in genericclass,http etc like as we wish to create infinate no of servlets can be created with
implements Servlet.
Added:
September
Comments: 2 Last Update: November 13, 2005 By svreddy Answer
28, 2005
20. How will u pass the argument from one servlet to another servlet?
we can use forward and include of requset dispatcher and the arguments would be request and
response for these methods

21. We have two applications in that we have two servlets each.How they(servlets)
communicate
with
each
other
?
connect both application with same data base1. 2. update the data close the connection 3
call the II app to Comments: 2 Last Update: October 23, 2005 By kailash Answer
Added: September 28, 2005 22. Is servlet is used to create a dynamic webpage or Static
webpage
or
both?
yes both servlet is used to create a static and dynamic webpage,it also create a static
webpage using serverside include it is .shtml extension,and so servlet is flexible
character. Comments: 0 Answer Added: September 28, 2005 23. Can a
init(ServletConfig
config)
method
be
overrided
in
servlets?
The init() method of servlet can be overridden. Remember the init() method is overloaded
in the GenericServlet class. But the difference lies in which init method are u calling..if
you override the init(ServletConfig config) method, then you will Comments: 5 Last
Update: November 09, 2005 By Bhupender Giri Answer Added: September 27, 2005
24.
When
you
have
action=get?
By default, every request sent is by GET. only when we explicitly mention that the
method is post, is the request sent by post.click meOn clicking the above link, the data is
send by get method.Here, when we submit the form, the data is sent via the Comments: 1
Last Update: September 30, 2005 By Anoop Kavalloor Answer Added: September 27,
2005 25. What methods will be called in which order?((i.e)service(),doget(),dopost())
Mainly we are talking about servlets life cycle.Here first init() ->service() ->wthin
servlets we use these method accordingly. ->destry(). Comments: 2 Last Update:
October 01, 2005 By brijesh Answer Added: September 27, 2005 26. what is the

importance
of
deployment
descriptor
in
servlet?
The deployment descriptor is not confined to servlets. It belongs to the application. The
deployment descriptor basically tell the container where to look out for the resources,
which patterns to follow, how are the resources mapped etc Comments: 3 Last Update:
November 08, 2005 By Anoop Kavalloor Answer Added: September 23, 2005 27. what
is
the
need
of
super.init(config)
in
servlets?
basically super.init() method should be used whenever u are overriding the init
method....else i dont think there is any necessity..... Comments: 3 Last Update:
November 09, 2005 By Anoop Kavalloor Answer Added: September 21, 2005 28. what
method
used
to
add
a
jsp
to
the
servlet
The RequestDispatcher.include(req, resp) is used to add a jsp to the servlet. Comments: 1
Last Update: September 21, 2005 By Chidambara Gupta. Cheedella Answer Added:
September 20, 2005 29. How the server will know (i.e) when it can invoke init,
service,destroy
methods
of
servlet
life
cycle?
init() method acts like a contructor, it is initilized when servlet is loaded.service() method
is first executed when servlets service is started.Note: service() method is override
implicitly for HTTP servlets, and should be overridden explicitly for Comments: 2 Last
Update: October 16, 2005 By Saffy Answer Added: September 18, 2005 30. What is
difference
between
Servelt
and
Applet
I don t KNOW
31. How many ServletConfig and servlet context objects are present in one application?
i wud like to clarify shyamalatha point.....there is only one servlet context for an entire
application where as for every servlet, there is a servlet config object....Using the servlet
context, a servlet can view the environment in which it is running Comments: 4 Last
Update: November 09, 2005 By Anoop Kavalloor Answer Added: September 16, 2005
32.
What is
a Singleton
class. How do you
write it
?
Anil Das Wrote: Singleton class can be created by defining the class static and making its
constructor private so that no other class can user the new() keyword to create the
instance of the singleton class. It will provide a public method which will Comments: 5
Last Update: November 09, 2005 By Anoop Kavalloor Answer Added: September 08,
2005 33. Servlet is Java class. Then why there is no constructor in Servlet ? Can we write
the
constructor
in
Servlet
we can't pass object of servlet config in the constructor.thats why we use only init()
method Comments: 3 Last Update: October 21, 2005 By savita Answer Added:
September 08, 2005 34. After converting jsp into servlet which methods are present i.e all
6 methods(jspinit(),_jspService(),jspDestroy(),init(),service(),destroy()) or only 3
methods i.e either jsp life cycle methods or servlet lifecycle methods
Servlets 3 methods we are getting . But we see only -jspService() Comments: 1 Last
Update: September 08, 2005 By veeru Answer Added: September 08, 2005 35. How to
know whether we have to use jsp or servlet in our project?
generally for small projects we use JSP model-1 where we use JSP for view and beans for
business logic.For large projects while implementing JSP model-2(MVC architecture) we
use JSP+Servlet+Java Beans,here JSP is used f Comments: 2 Last Update: October 31,
2005 By manikant Answer Added: September 08, 2005 36. Why is that we deploy
servlets
in
a
webserver.What
exactly
is
a
webserver?
Web server This is nothing but Program written in Java etc.Ex:Tomcat 5.0 The webserver

is exactly running in the JVM.so,whataver the program is written for Tomcat is running
in JVM and displaying. Comments: 1 Last Update: September 08, 2005 By veeru
Answer Added: September 08, 2005 37. How to get one Servlet's Context Information in
another
Servlet?
Access or load the Servlet from the Servlet Context and access the Context Information
Comments: 1 Last Update: September 08, 2005 By veeru Answer Added: September
08,
2005
38.
What
is
the
Servlet
Interface?
The central abstraction in the Servlet API is the Servlet interface. All servlets implement
this interface, either directly or, more commonly, by extending a class that implements it
such
as
HttpServlet.Servlets-->Generic
Servlet-->HttpServlet-->MyServlet.The
Comments: 1 Last Update: September 08, 2005 By veeru Answer Added: September
08, 2005 39. If you want a servlet to take the same action for both GET and POST
request,
what
should
you
do?
Simply have doGet call doPost, or vice versa. Comments: 1 Last Update: September 08,
2005 By veeru Answer Added: September 08, 2005 40. What is the difference between
ServletContext
and
ServletConfig?
Both are interfaces. The servlet engine implements the ServletConfig interface in order to
pass configuration information to a servlet. The server passes an object that implements
the ServletConfig interface to the servlet's init() method.The ServletContext
41. What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the
"method" will append all of the data to the URL and it will show up in the URL bar of
your browser. The amount of information you can send back using a GET is restricted
Comments: 10 Last Update: October 18, 2005 By phanidhar Answer Added:
September 08, 2005 42. operations performed on vector are either posing a value into the
vector (or) retriving a value from the vector . which operation is synchronized
Vectot is a legacy class and its synchronized, which means whatever operations
performed on Vector is synchronized Comments: 2 Last Update: September 27, 2005
By Vinod Answer Added: September 03, 2005 43. when we increase the buffer size in
our project using page directive attribute 'buffer' what changes we observe?
When you increase the buffer size in jsp using the buffer tag then it means that you are
increasing the data holding capacity of the buffer. When you access the jsp(incresed
buffer size) then the user will observe that the page is loaded with data slowly.I
Comments: 1 Last Update: September 19, 2005 By Satyasudheer Answer Added:
September 03, 2005 44. What is difference between sendRedirect() and forward()..?
Which one is faster then other and which works on server?
Actually when we use sendRedirect method then u r changing or transfering the request
to new URL.Mean new URL is formed .In case of Forward method of RequestDispatcher
your context is not changed means ur URL object remains same.Since URL is same so
forward() Comments: 5 Last Update: November 09, 2005 By Kiran Answer Added:
September 02, 2005 45. How to communicate between two servlets?
ANS: Two ways:1. Forward or redirect from one Servlet to another.2. Load the Servlet
from ServletContext and access methods. Comments: 2 Last Update: September 21,
2005 By Chidambara Gupta. Cheedella Answer Added: August 29, 2005 46. What is a
better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface
or
Synchronization?

Although the SingleThreadModel technique is easy to use, and works well for low
volume sites, it does not scale well. If you anticipate your users to increase in the future,
you may be better off implementing explicit synchronization for your shared data.
Comments: 1 Last Update: August 27, 2005 By vamshidhar Ghanpur Answer Added:
August 27, 2005 47. do we have a constructor in servlet ? can we explictly provide a
constructor
in
servlet
programme
as
in
java
program
?
constructor is desault in servlets. We can write constructor for the servlet. But there is a
problem with the initalization of parameters. So we don't provide initilization parameters
with in this constructor. Comments: 7 Last Update: August 24, 2005 By karan Answer
Added: August 24, 2005 48. What is servlet context and what it takes actually as
parameters?
Another very important and practical application of ServletContext that i have come
across is that it can be used to hold the object which can generate request independent
and non-static data. Suppose we want that our servlet should dispaly a particular
Comments: 2 Last Update: August 22, 2005 By Sumit Sengar Answer Added: August
22, 2005 49. What is the difference between JSP and SERVLETS
The Difference between JSP and Servlets is JSP separates the Business logic from
presentation logic. Comments: 7 Last Update: September 27, 2005 By Suman Kumar
Gattu Answer Added: August 19, 2005 50. How Servlet Applet communication
achieved?
Use URLConnection class and call URLConnect. openConnection &
URLConnection.connect method

Вам также может понравиться