A class which must create only one object (ie. One instance) irrespective of any number of object creations based on that class.
Steps to develop single ton class:-
1.Create a Private construcor, so that outside class can not access this constructor. And declare a private static reference of same class
2.Write a public Factory method which creates an object. Assign this object to private static Reference and return the object
Sample Code:-
class SingleTon
{
private static SingleTon st=null;
private SingleTon()
{
System.out.println(“\nIn constructor”);
}
public static SingleTon stfactory()
{
if(st==null)
st=new SingleTon();\
return st;
}
}
2) What is the difference between using HttpSeassion & a Stateful Session bean? Why can't HttpSessionn be used instead of of Session bean?
HttpSession is used to maintain the state of a client in webservers which are based on Http protocol. Where as Stateful Session bean is a type of bean which can also maintain the state of the client in Application servers based on RMI-IIOP
3)Question on Seggregation in UML?
4)What is Temporary Servlet?
When we sent a request to access a JSP, servlet container internally creates a 'servlet' & executes it. This servlet is called as 'Temporary servlet'. In general this servlet will be deleted immediately to create & execute a servlet base on a JSP we can used following command.
Java weblogic.jspc—keepgenerated *.jsp
5) Generally Servlets are used for complete HTML generation. If you want to generate partial HTML's that include some static text (this should not be hard coded in servlets)
as well as some dynamic text, what method do you use?
Using 'RequestDispather.include(“xx.html”) in the servlet code we can mix the partial static HTDirectoryML page.
Ex:- RequestDispatcher rd=ServletContext.getRequestDispatcher(“xx.html”);
rd.include(request,response);
6)Difference between
*) In both the cases single Request proceses multiple resources.
7) Purpose of
It is used to generate client broser specified HTML tags which results in download of the java plugin sofware. And the execution of the applet or java Bean component that is specified in the tag.
8) The time between Command Execution and Response is called?
9)Which method is called first each time a Servlet is invoked?
When the servlet obj is not created init() method will be called. It servlet obje is already exists 'service() method will be called.
10)Tell about EJB tranctions and how to manage them?
11)Why DB connections are not written directly in JSP's?
The main purpose of JSP is to seperate the business logic & presentation logic. DB connections deal with pure java code. If write this kind of code in JSP, servlet container converts the JSP to servlet using JSP compiler which is the time consuming process so this is better to write code wich deals with DB connections, Authentication and Authorization etc. in the java bean and use the
12)What is key diffrence between using a
Ans: The
Where as in the case of Response.sendRedirect() the request to be forwarded/redirected to another resource in the same web-application or some other web-application in the same server, or to a resource on solme other web-server. The key difference is by using
13)Why beans are used in J2EE architecture instead of writing all the code in jsp's?
In order to seperate the business logic and presentation logic beans are used. We write the business logic in the Beans. Where there is a change in business process we have to modify only the bean code not jsp code and viceversa.
14)How can a servlet can call a JSP error page?
By simply includeing an
< error-page>
< exception-type> javax.servlet.ServletException
By using Response.sendRedirect(“error.jsp”); or by using RequestDispatches.forward(“error.jsp”); we can call jsp error page in servlet.
15)What exception is thrown when Servlet initalization fails?
ServletException . since init() throws ServeletException .
16) Explain MVC (Model-View-Controller) architecture?
MVC:- In model view controller design pattern, the software has split into 3 pieces.
MODEL-> Responsible for Managing Data-> Ex. Java Beans
VIEW-> Responsible for generating the views->Ex. Jsp's
CONTROLLER-> Responsible for user interactions & co-ordinate with MODEL &VIEW
17)What are the design patterns? Explain FACADE Design Pattern?
18) How do you perform testing? Do you use any automated testing tools? If so, what are they?
19)Difference between Application Server & Web server?
Web servers are used for running web applications, the features are very less to compare application server the application server is specific to application. And it can run all the application including web application.
Ex:- weblogic,websphere, Jbose.
All are providing the more features than websever like tomcat.
Application servers used for enterprise solutions, webservers are used middle tier webapplications. We can
20)JSP implicit Objects:-
1)out: used to send the content to the browser
ex: out.println(“xx”)
2)Response: Represent HttpServlet Reques
3) Response: Represent HttpServletResponse
4) Page Context: used to access the objects like session, servlet context, Request, Response etc...
5) Session: Points to HttpSession objects
6) Application: Points to servlet context objects
7)Page: Points to current servlet objects
8) Exception: Points to Exception
21)JSP Action Tags, Directive Tags & Scripting Tags?
Action Tag: These tags effect the runtime behaviour of the jsp page and the response
set back to client tags are :
< jsp: setProperty>: setting the properties at runtime
Directives:
These tags effect the overall structure of the servlet that result from translation. 3 types of directives are defiend.
Page directive: used to define and manipulate the no of page dependent attributes that effect the whole jsp.
<%@page.......%>
include directive: This instructs the container to include the content of the resource in the current jsp
.<%include file=”-----”/>
this file is parsed once, when translation.
Taglib directive: To use tag extendtions to define custom tags.
Scriptlets: There are used to include javacode in jsp page these are of 3 types
scriptlet: used to write pure java code
<%----------%>
declarations: used to declare java variables and methods
<%!int num=3;
public void hello(String str)
{
return str;
}
%>
Expressions:
This send the value of a java expression back to client. These results is converted to string and displayed at client.
22)
To saparate the code from the presentation it would be good idea to encapsulate the code in java object instantiate it and use it in our jsp. This instance is varaible is called 'id'.
We can also specific life time of this object by using 'scope' attribute
Properties:
id: a case sensitive name is used.
Scope: The scope with in which the reference is available. page, request,session, application are possible values
page is default
class: the fully qulified classes name
beanname: The name of the java beanclass
type: This type must be super class of the beans classes
23)How do you implement Singe Thread Model in JSP?
By simply include a page directives
<%@page isThreadSafe=”false” %>
24)How do you declare a page as Erro Page. What tag you include in a JSP page so that it goes to specified error page in case of an exception?
By includeing a page directive
<%@ page isErrorPage=”true”%>
then this page is including a page directive in our jsp pages
<%@pase errorpage=”url of the above jsp”%>
calling this page is including a page directive in our jsp page
<%@page errorpage=”url of the above jsp”%>
25)Difference between Include Directive & Incude Tag?
26)Servlet is a java class. So, can there be a constructor in Servlet class or not? Why?
Include Directive Include Jas
<%@include file=”url”%>
It includes static content It include static or dynamic content
This is parsed by container This is not parsed but included in place
27)What is a servlet Context? How do you get it?
ServletContext is also called as applicatin object . And this can be used for logging(stores some kind of information ) getting context parameters, getting the request dispatcher and storing the global data.
We can get the serveletcontext using ServeletContext.
i.e ServletContext sc = getServletContext();
28)What is Servlet Config? How do you get it?
ServletConfig can be used to get the initiallization Parameters, to get the reference to the ServeletContext. There can be multiple serveletconfig objects in a webapplication.
Each servelet has one Config object.
The configration information is:
servlet name, initalization parameters servlet context object.
29)What is Request Dispatcher? How do you get it?
The name itself reveals that it is used todispatch the control to requesting resource. It is an interface used to include any resource with in our servlet or forward the controoler to any other resource. It contains two methods.
Forward(“---url”);
forward(“---url”);
For getting this we have a method in servlet context interface. So we can get it by servlet context object
sc.getRequestDispatcher();
30)Tag Libraries, their syntax, & usage?
31) Difference between JSP & Servlets?
Both are webapplications used to produce web content that mean dynamic web pages. Bot are used to take the requests and service the clients. The main difference between them is, In servlets both the presentation and business logic are place it together. Where as in jsp both are saparated by defining by java beans .
In jsp's the overall code is modulated so the developer who deesn't know about java can write jsp pages by simply knowing the additional tages and class names.
One more important to be considered is servlet take less time to compile. Jsp is a tool to simplify the process and make the process automate.
32)Difference between Hashtable & HashMap?
Hash table is a Collection .To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method. Hashtable is Sychronized and permit not null values only.
Hashtable maps keys to values. Any non-null object can be used as a key or as a value.
The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.
33) Question on Collections framework?
The Collection API is set of classes and interfaces that support operations on
Collections of Objects.
34) By default, Hastable is unordered. Then, how can you retrieve Hastable elements in the same order as they are put inside?
we can retrieve hashtable elements in the same order by using the method elements which returns enumeration.
35) About “Map” data structures in Collections framework?
A map cannot contain duplicate keys; each key can map to at most one value. The Map interface provides three collection views, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map's collection views return their elements.The TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not.
36)Life Cycles of beans?
37)Isolation levels & Transaction levels?
The isolation level measures concurrent transaction's capacity to view data that have been updated, but not yet committed, by another transaction if other transactions were allowed to read data that are as yet uncommitted, those transactions could end up with inconsistent data were the transaction to roll back, or end up waiting unnecessarily were the transaction to commit successfully.
A higher isolation level means less concurrence and a greater likelihood of performance bottleneck, but alos adecreased chance of reading inconsistent data. A good rule of thumb is to use the highest isolation level that yields an acceptable performace level. The following are commin issilation levels, arranged from lowest to highest.
1) ReadUncommitted: Data that have been updated but not yet committed by a transaction my be read by other transactions
2) Readcommitted: Only data that have been committed by a transaction can be read by other transactions.
3) Repeatable Read: Only data that have been commited by a trasaction can be read by other transactions, and multiple reads will yield the same result as log as the data have been committed.
4) Serializable: This highest possible iosolation level, ensures a transaction's execlusive read-write access to data, it includes the conditions of ReadCommitted and Repeatable Read and stiplulates that all transactions run serially to achieve maximum data integrity. This yields the slowest performance and least concurrency. The term serializable in this context is absolutely unrelated to the database.
38)ejbActivate() Vs ejbPassivate(), ejbCreate() Vs ejbPostCreate(), ejbLoad() Vss ejbStore(). Which type of EJB can use bean pooling? How can you call an EJB from a JSP/servlet?
EjbCreate() is called before the state of the bean is written to the presistence storage. After this method is completed, a new record is created and written to the presistence storage. If you are developing an EJB following 2.0 specs, you can have overloading methods in the form of ejbcreatexxx(). This will improve the development so you can have different behaviour for creating a bean, if the parameters differs. The only requirement is that for each ejbCreatexxx() you need to have corrisponding createxxx() methods in the home or local interface. EjbPostCreate() is called after the bean has been written to the database and the bean data has been assigned to an EJB object. So when the bean is available. In CMP, this method is normally used to manage the beans container-managed relationship file
39)How to configure Data Source in WebSphere server?
40)How you manage configuration control?
41) What is a singleton class?
42)How do you send data from an applet to Servlet? What are the steps involved in it?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
Directory
43)I have a file of very very large file size at client side, and i want to send the file to a servlet(this servlet will store it somewhere), what is the best method to do it?
44)What is the difference between normal beans and EJBs?
JavaBeans may be visible or nonvisibleat runtime. For example, the visual GUI component may be a button, list box, graphic, or a chart An EJB is a nonvisual, remote object
Java Beans are intended to be local to a single process and are primarily intended to run on the client side. Although one can deevelop server-side JavaBeans, it is far easier to develop them usin the EJB specification instead. EJBs are remotely executable components or business objects that can be deployed only on the server
JavaBeans is a component technology to create generic java component that can be composed together into applets and applications Even though EJB is a component technology, it neither builds upon nor extends the original javaBeans specification.
Java Bean have an external interface called the properties interface, which allows a builder tool to interpret the functionality of the bean EJBs have a deployment descriptor that describes its functionality to an exteternal builder tool or IDE
45)How system level services in EJBs are managed? And tell about Deployment Descriptor?
50) In webLogic clusters, what is the load balancing algorithm
Load Balancing for servlets & jsps
Load Balancing for EJB &RMI objects
Load Balancing for JMS
Load Balancing for JDBC connection
Round Robin Load Balancing
Weight based load Balancing
Random Load Balancing
Round Robin, weight based & Random affinity.
46)What are various types of EJBs?
We have 3 types of EJB's
1) Seasion Beans:
Stateless Seasion bean
Stateful Seasion bean
Session beans are mainly used to implement business process applications
2) Enatity Beans:
Entity beans used to manage business entites
Bean Managed Persistance beans(BMP):--we need to write jdbc code to manage business data
Container Managed Persistance bean(CMP):--Tools supllied as part of the container generates the jdbc code for managing the data
3) Message Driven Beans: Used to implement business processing and Business Data
47)What is the purpose of ejbLoad()?
With CMP , the bean developer doesnot need to write any database access logic into the bean, but bean is notified by the container when its state is synchronized with the database. The container notifies the bean using the ejbLoad() and ejbStore() methods.
The ejbLoad() method alerts the bean that its container-managed fields have just been
populated with data from the database. This gives the bean an opportunity to do any post processing before the data can be used by the business methods.
The ejbStore() method alerts the bean that its data is about to be written to the database. This give the bean an opportunity to do any pre-processing to the fields before they are written to the database.
The BMP bean manges its own persistance , but relies on the container to coordinate
its reads and writes so that persistance is accomplished in a transactional safe manner. Coordination with the container is accomplished through two mechanisms:
the persistance callback methods [ejbLoad() and ejbStore()] and the Environment Naming Context (EJB).
The ejbLoad() and ejbStore() methods notify a bean that its time to read and write
data to the database respectively. In a BMP entity bean the code for reading and writing data to the database is done with in these methods . The ejbLoad() is called at the beginning of transaction, just before any business methods are executed , and the ejbStore() is called at the end of a transaction just before its commited. This keeps the bean state in perfect synchronization with transactions being executed , without the bean developer having to explicitly manage the transactional operation.
48)What is the purpose of ejbStore()?
49)What is the purpose of XML?When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
50) In webLogic clusters, what is the load balancing algorithm
Load Balancing for servlets & jsps
Load Balancing for EJB &RMI objects
Load Balancing for JMS
Load Balancing for JDBC connection
Round Robin Load Balancing
Weight based load Balancing
Random Load Balancing
Round Robin, weight based & Random affinity.
51)How many Queues does a MDB listen to?
52)Where is the Deployment Descriptor placed?
Deployment Descriptors gives the information about our resources used in our application to the server. To avoid the hand coding we used these deployment descriptors. Which are placed under ‘WEB-INF’ directory as an .xml file
53)Can a JSP be converted to SERVLET and the vice versa always?
We can convert a JSP to servlet but it is not possible in case of servlet to a jsp. Usually server takes the responsibility of converting a JSP to a servlet based on .tld files and taghandlers. But there is no server which takes servlet as input and gives jsp file as output.
54)About EJB types,CMP,BMP,session, Entity beans?
Used for implementing business processing session beans are divided into two types
1) Stateful Session Bean
2) Stateless Session Bean
In stateful Bean, state of the session is maintained. It takes more memory to maintain the state for each object. If there are 100 clients/requests. The server maintains 100 stateful beans each bean for a client. In stateless session Bean, no need to maintain the state of a bean.
ii) Entity Beans: used to manage business data
BMP: we need to write jdbc code for managing data
CMP: code to manage the data will be generated by the tools.
iii) Message Driven Bean: Used for implementing business process ( some as session beans use). This will be driven by message.
55)Can a client Context call ebjRemove() method?
In ejbRemove() method will be called before removing the object, it is similar to destroy() method in servlets. In case of stateless session bean we can’t call ejbRevove() method from client context. It depends upon the server when to remove on delete the object from the server
In case of stateful session bean. The client can call ejbRemove() method by calling remove method to remove the object from the server. In case of entity beans, ejbRemove() method means deleting the data from two database. It can be called from the client context.
56)Which is faster in execution-JSP or SERVLET ? Why?
Servlet is faster in execution as every jsp is changed on converted to servlet before starting the execution. Thus the server need to spend some time to convent a JSP file to servlet at it’s first time execution. But developing a jsp is very easy when compared to servlet.
Every time before executing a jsp & server searches for related servlet file. If it existsWhen ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
then start the execution of that servlet otherwise server creates servlet files for those jsps first and then execution takes place
57) What is the difference between Callable Statement and Prepared Statement?
Callable statement are used to call the stored procedures in a database where as prepared statements are used to provide dynamic input for the statement.
58)Can we declare final method in abstract class?
If a method is defined as final then we can’t provide the reimplementation for that final method in it’s derived classes i.e overriding is not possible for that method.
An abstract class constains one or mole abstract method. If all the methods ar of type abstract then use we can declare that class as abstract or interface. But in interface all the methods must be of type abstract.
We can declare final method in abstract class suspose of it is abstract too, then there is no used to declare like that.
Final abstract int test(String str);
Here we can’t provide the implementation for the test method as it is declared as final. But at the same time you declare it as abstract. [Abstract means it is responsibility of derived class to provide implementation for this] Here we can’t provide the implementation for the test method. Even we descried to provide implementation totally our meaning for declaring it as abstract is spoiled.
59) Can we declare abstract method in final class?
It indicates an error to declare abstract method in final class. Because of final class never allows any class to inherit it.
60)How can you pass an object of data from one JSP to anoter JSP?
61) Can the same object os Stateless Session bean be shared by multiple clients? Can the same object os Stateful Session bean be shared by multiple clients?
It is possible to share the same object of stateless session bean by multiple clients.
A Server maintains a pool of objects in case of stateless session bean. And every When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
time for a request it uses one of the pool of objects which is free at that time. The server gets back that object in to the pool only after the client work on that object is Directoryover [ client says that by invoking ejbremove() method]
After the client release that object, the server may used the same object to handle another client request, thus the same object to handle another client request. Thus the same object of stateless session can be shared by multiple clients But sharing the same object for multiple clients is not possible in case of state full session bean. Here server should maintain an object for every clients to handle / maintain the state of that object.
62)In java, which has more wider scope? Default or Private?
Default has more scope than private
Private: accessible only to the members of that class where it is defined.
Default: We can access this from any class in the program/file
63)Design Pattern?
Design pattern is a solution for recurring (reoccurring ) problems. Any one can provide best solution for a problem which is occurring repeatedly or often and we can give any name for that solution is known as design pattern.
64)Which Design Pattern hides the complexities of all sub-systems?
65)Which bean can be called as Multi-Threaded bean?
Stateless session bean can be called as Multi-Threaded bean as for every request of users is handled by creating a new threaded for the same object.
66) In CMP bean, which method executes only once in life time?
67)What is the difference between Server and Container?
A server provides many services to the clients, A server may contain one or more containers such as ejb containers, servlet/jsp containers……etc. Here a container holds a set of objects.
68)How will u authentication a user?
69)Difference between SAX and DOM?
SAX stands for Simple API for XML. It is a standard interface for event based XML parsing. Programmers provide handlers to deal with different events as the document is passed.
If we use SAX API to pass XML documents have full of control over what happens when the event occur as result, customizing the parsing process extensively. For example a programmer might decide to stop an XML document as as soon as the parser encounters an error that indicate that the document is invalid rather than waiting until the document is parsed. Thus improve the performance.
DOM stands for Document Object Model. DOM reads an xml document into memory and represents as it as tree. Each node of tree represents a particular piece of data from the original document. The main drawback is that the entire xml document has to be read into memory for DOM to create the tree which might decrease the performance of an application as the xml document get larger.
70)Have u ever used
The extensively Stylesheet Language (XSL) is a W3C standard for describing a presentation rules that applied to xml documents. XSL includes both transformation language an d formatting language. XSLT is an xml based language and W3C specific that describes how to transform an xml document into another xml document.
71)Which loads driver classloader or JVM?
72)Types of Drivers in JDBC?
Types of drivers in JDBC
Type 1 : JDBC –ODBC Bridge Driver
Type 2 : Native API Partly Java Driver
Type 3 : JDBC Net pure Java Driver
Type 4 : Native Protocol Pure Java Driver
73)How to implement connection pooling by ourself?
74) Will service all doget,dopost or the reverse?
75) How can u implement connection pooling by ourself?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
76)How can u implement hasmap if u r not having it in java?
77)How will u declare a synchronized block? What does this represent in the Declaration of sunchronized block?
When two or more threads need to access to a shared resource they need some way to ensure that the resource will be used by only one thread at a time. The process by which this achieved is called synchronization.
The general form of synchronize statement :
Synchronized (object) {
// statement to be synchronized
}
here the object is a reference to the object being synchronized. A synchronized block ensures that a call to a method that is member of object occurs only after the current thread has successfully entered the object’s moniter.
78) What is servlet chaining?
One servlet output will give as a intput of another servlet in servlet chaining.
79)What is dynamic bindig? Can u explain with an example?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
80)Can u read all elements from any array?
81)What is event delegtion model? Describe it with an example?
The event Delegation model defines standard and consistant mechanisms to generate and process events. A source generates and event and sends it to one or more listeners. The listeners simply waits until it receives an event. The advantage of this design is that the application logic that processes events is cleanly separated from the uses interface logic that generates those events.
82)What is a tier? What is the difference between tier and system or computer?
83)What do u mean by portability?
In c and c++ sizeof() operator tell us the number of bytes allocated for data items. Different data types might be different sizes on different machines, so the programmer must find out how big those types are when performaing operations that are sensitive to the size. For example one computer might store integer in 32 bites, where as another might store integers as 16bits. So the java does not need a sizeof() operator for this purpose because all the data types are the same size on all machines. We need not think about protability.
84)What is translation unit in jsp?
When we create a source code file for java its commonly called a compilation unit or translation unit.
85) What is context in webapplication?
86)What are multiple and single processor servers? How session is handled when the server is multi processor server?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
87)If server crashes the threads will continue running or will they stop? What happens to the servlet?
88)Explain MVC pattern by taking any one component ex JtextField or Jbutton?
89) What is pooling of servlet?
Whenever a request is called it picks up the instance of that servlet from a
Container which contains the number of instances from it & this is maintained by the controls that is web.xml
90)Why cocoon? Why not struts? What is cocon?
91)How are u implementing session in ur applicatin?
The web containers can create the session objects on behalf of client request. For accessing this session objects we need to use “ request.getSession(Boolean value);”
For every session object it is creating a sessionID to generate
92) What is serialization? What are the method in implementing serialization?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. ThDirectoryen the web container runs the jsp compiler that generates the servlet code
93) Why jsp is used if we have servlets?
Java server pages are designed to simplify the process of developing a web application on the top of servlet technology
94)Is servlet threadsafe?
Yes Servlet is a thread safe by implementing the single thread model we can fulfill this.
95) What happens when jsp is called?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
96)When Jsp code changes, how the servlet is reloaded?
When ever we send a request to the JSP file it checks the servlet representing the JSP file. Then the web container runs the jsp compiler that generates the servlet code
97)What is difference between StateFul and Satateless Session Bean?
98)What is difference between Bean ManagedPersistance and Container ManagedPersistance?
IN the case of Bean Managed Persistant we need to write the manual coding but in the case of container managed persistant bean the tool itself will generate the code to satisfy our requirements
99) Difference between forware(request,response) and SendRedirect(url)inservlet?
In the case of forward (req, res) the outputs generated by the first servlet will be discarded but only the output generated by the second servlet will be send to the client . But in the case of send redirect() will be setting the status code & pointing to the new url.
100)Draw & explain MVC Architectur?
101) What is synchronize?
With respect to multithreading , synchronization is the capability to control the access of multipul 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.
102)How to prevent Dead Lock?
We can prevent this Dead Lock by implementing synchronization proceder & improve the efficiency of the Application.
103)How Servlet Maintain Session and EJB Maintaine Session?
104)Difference between HasMap and Hash Table?
In the case of Has Maps there is no synchronizable in the case of Has Table it is synchronizable and thread safe but it is slow in performance.
105)Difference between Swing and AWT?
AWT is heavey weight , where as Swings are light weight. These two are using to implement GUI applicatins.
106) Types of Enterprise Bean?
1)Session Beans.
2)Entity Beans
3)Bean managed persistant Bean.
4)Containes Managed persistant Bean
5)Message Driven Bean.
The above 5 are the Enterprise Entity Beans.
107)Service of EJB?
The EJB provides the following services
a)concurrency
b)Transaction Management
c)Persistancy
d)Security
e)Threading
f)Synchronization
g)Object cashing
h)Object Naming
i)Object activation
j)Object serialization
k)Object sharing
l)Object communication
m)Object Decision
108)Why not to use free J2EE servers?
109)Alternative:Tuxedo
110)J2EE server offeres?
It offers servlets, JSP,JNDI,JDBC & structs.
111)Java Naming and the Directory Service?
It is Noting but Java Native Device Interfaces where we can store our remote object inside the file & this is used to identify the Home object
112) XML deployment descriptor?
It is nothing but web.xml where we can store all the resource information of all the objects inside this file
113) Entity Bean session Bean where to use which Bean? Container Types:
114) What is the Max amount of information that can be saved in a Session Object?
As such there is no limit on the amount of information that can be saved in a Session Object. Only the RAM available on the server machine is the limitation. The only limit is the Session ID length(Identifier) , which should not exceed more than 4K. If the data to be store is very huge, then it's preferred to save it to a temporary file onto hard disk, rather than saving it in session. Internally if the amount of data being saved in Session exceeds the predefined limit, most of the servers write it to a temporary cache on Hard disk.
115) How to confirm that user's browser accepted the Cookie?
There's no direct API to directly verify that user's browser accepted the cookie. But the quick alternative would be, after sending the required data tothe users browser, redirect the response to a different Servlet which would try to read back the cookie. If this Servlet is able to read back the cookie, then it was successfully saved, else user had disabled the option to accept cookies.
116) How do i get the name of the currently executing script?
Use req.getRequestURI() or req.getServletPath(). The former returns the path to the script including any extra path information following the name of the servlet; the latter strips the extra path info. For example:
URL http://www.javasoft.com/servlets/HelloServlet/jdata/userinfo?pagetype=s3&pagenum=4
getRequestURI servlets/HelloServlet/jdata/userinfo
getServletPath servlets/HelloServlet/
getPathInfo /jdata/userinfo
getQueryString pagetype=s3&pagenum=4
117) What are Good Ways of Debugging a Servlet? Are IDE's which support Servlet Debugging?
There are couple of Methods. Firstly servers like JRun and others provide separate logs where all your Print requests will print their data into. For example requests to System.out. and System.err go to different log files. If this features is not available or you want to maintain logs separately for each module then you can create a static class called "LogWriter" and call the method inside the try catch loop. The print method in Log Writer will be writing to a custom defined Log File.
try
{ ....
}
catch(Exception exp)
{
LogWriter.print("Debug : The following error occurred at function .... ')
}
Also Inprise JBuilder supports Servlet Debugging. Please refer to JBuilder documentation for details.
Just as a Cautionary note, from your Servlets, never call System.exit(0). The results might be unpredictable. Might close down the entire Server. The Best way is to catch the Exception and either send resultant Error Page to the Browser or Write to a Log file and inform user about the Error.
118) How do I know when user Session has expired or removed?
119) How can i stress test my Servlets?
You can use one of the following products to stress test your Servlets.
ServletKiller From Allaire Software (Free Product)
E-Load from RSW Software
Web Application Stress Tool From Microsoft
JMeter from Apache
120) What is Server Side Push and how is it implemented and when is it useful?
Server Side push is useful when data needs to change regularly on the clients application or browser , without intervention from client. Standard examples might include apps like Stock's Tracker, Current News etc. As such server cannot connect to client's application automatically. The mechanism used is, when client first connects to Server, (Either through login etc..), then Server keeps the TCP/IP connection open.
It's not always possible or feasible to keep the connection to Server open. So another method used is, to use the standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers.
This will refresh the page in the browser automatically and loads the new data every 5 seconds.
121) What is the difference between Multiple Instances of Browser and Multiple Windows? How does this affect Sessions?
From the current Browser window, if we open a new Window, then it referred to as Multiple Windows. Sessions properties are maintained across all these windows, even though they are operating in multiple windows.
Instead, if we open a new Browser, by either double clicking on the Browser Shortcut icon or shortcut link, then we are creating a new Instance of the Browser. This is referred to as Multiple Instances of Browser. Here each Browser window is considered as different client. So Sessions are not maintained across these windows.
123)Difference b/w jsp:forward and request.sendRedirect.
124)Using which obj we can call trasnsaction control statements.
125) Question on native with synchronized is it possible?
126) Can more than one will have his state in stateful session bean?
127) How u can database operations used in stateful session bean?
128) What do we use as path in xml?
129) What is struts?
130) Explain MVC Architecture?
View : - The UI view involves the presentation layout(the actual HTML output), for the result of the interaction . For HTML clients, this can be done using JSP.
Controller : - presentation logic (the logical connection between the user and EJB services), necessary to process the HTTP request , control the bussiness logic, and select an appropriate response . This can be provided by Java Servlets or Session Beans.
Business logic (Model) :- The business logic ( the core business transactions and processing ), necessary to accomplish the goal of the interaction ( calculations, queries , and / or updates to a database ,etc). Business logic should be separated from UI logic. This makes it possible to have different clients( for ex browser and GUI) using the same beans . Separating the 2 also makes the business components easier to re-use , maintain, and update or change.
131) How you can create servlet objects at the time of web application starts?
a) if we use configure a servelet using Load-on-startup the webContainer creates our servlet object when we deploy the webapplication.
b) when we undeploy the webapplication the webcontainer destroys ( removing the object from JVM destroys the servelet object ).
132) Suppose i created 5 servlet objects dynamically and i make a request to the container, the which object will give to me?
133)What is the difference between servlet config and servlet context?
There will be only one ServletContext object for a webapplication.
There can be multiple ServletConfig objects in a single webapplication.
Servlet Config can used get Parameters
134) How you can create a connnection object in weblogic? And how you can access that object?
135) What is difference between jsp:forward and Reqdisp.forward()?
136) What is difference between Req.sendRedirect and reqdisp.forward()?
137) How you can insert values into a table without writing the code()?
138) How you can call a jsp from a servlet and vice versa?
139) What is the difference between jsp writer, printwriter?
140) What are the implicite variables in jsp?
141) How may ways you can use threadclass and in which situation you can be use runnableinterface?
142) What is the difference between string and String Buffer?
143) What is the difference between SAX and DOM?
144) If we can implement a constructor in a servlet? What will be happen?
145) What is difference between stateless and stateful session beans?
Stateless:
1) Stateless session bean maintains across method and transction
2) The EJB server transparently reuses instances of the Bean to service different clients at the per-method level (access to the session bean is serialized and is 1 client per session bean per method.
3) Used mainly to provide a pool of beans to handle frequent but brief reuests. The EJB server transparently reuses instances of the bean to service different clients.
4) Do not retain client information from one method invocation to the next. So many requir the client tomaintain on the client side which can mean more complex client code.
5) Client passes needed information as parameters to the business methods.6) Performance can be improved due to fewer connections across the network.
Stateful:
1) A stateful session bean holds the client session's state.
2) A stateful session bean is an extesion of the client that creates it.
3) Its fields contain a conversational state on behalf of the session object's client. This state describes the conversation represented by a specific client/session object pair.
4) Its lifetime is controlled by the client.
5) Cannot be shared between clients.
146) What are the disadvantatges of CMP?
147) Structs concept you are implementing on model1 or model2?
148)What in an interface?
149)What are the difference between interface and abstract class?
The key difference between an interface and the corresponding abstract class is that a class or interface can have unlimited number of immediate super interface but it can only hace one super class.
There are two primary axes of “inheritance” an object-oriented language like java. Implementation inheritance is where the sub-class inherits the actual code implementation from the parent. Interface inhyeritance is where the sub-class adheres to the public interface of the parent.
Also java actally mixes the two notions together a bi.... java interfaces are nice and clean. When you implement an interface, you are stipulating that your class adheres to the “contract” of the interface that you spefified. Java class inheritance isn't so clean when you sub-class in java you are getting both the code inheritance but you are also stipulating that you sub-class adheres to the contract of the interface of the parent class.
Abstrct class in java are just like regular java classes but with the added constraint that you cannot instance then directly. In terms of that added constraint, they are basically classes which don't actually implement all lof the code specified by their “contract”.
150) How you can access the implementation from the database to JSP/Servlet?
151) How you can get connection object from weblogic?
A checked exception is an exception that must be dealt with in the code, either by catching it or by specifying a throws clause. Checked exceptions are all exceptions that are subclassed from Exception except RuntimeException. An unchecked exception is an exception that need not be dealt with programmatically. It includes RuntimeExceptions (and its subclasses) and Error and its subclasses. ==================================================================== Checked vs. unchecked exceptions There are two kinds of exceptions in Java, checked and unchecked, and only checked exceptions need appear in throws clauses. The general rule is: Any checked exceptions that may be thrown in a method must either be caught or declared in the method's throws clause. Checked exceptions are so called because both the Java compiler and the Java virtual machine check to make sure this rule is obeyed. Whether or not an exception is "checked" is determined by its position in the hierarchy of throwable classes. Figure 4 shows that some parts of the Throwable family tree contain checked exceptions while other parts contain unchecked exceptions. To create a new checked exception, you simply extend another checked exception. All throwables that are subclasses of Exception, but not subclasses of RuntimeException are checked exceptions.
152) How you can send parameters to a servlet?
153) How you can create global parameters that is the parameters which are used by all the servlets?
154) How many types of transactions are supported by EJB? What are they tx-support,tx-no.supported what is the difference between tx-required,tx-not supported?
REQUIRED : Method calls require a transaction context. If one exists , it will be used ; if none exists, one will be created.
Can use Existing Transaction.
If not already in transaction will start new one , commit when method completes.This transaction attribute should be used when ever the bean is accessing any transactional
resouce manager. ForEx: a bean accessing a database through JDBC should use the transaction attribute Required. You should use this if you want the operation to always run in a transaction.
TX- NOT-SUPPORTED :
The bean runs out side the context of a transaction. Existing transactions are
suspended for the duration of method calls.
Does not execute in a Transaction.
Existing transaction is suspended.
This transaction attribute can be used when the resource manager responsible for transaction
is not integrated with the application server. ForEx, if the bean method is invoking an operation on a SAP System which is not integrated with the application server, the server has no control over the transactions happening at the SAP system. In such a case , it is best to set transaction attribute of the bean to be Not-Supported.
155) Explain about checked and unchecked exceptions?
A checked exception is an exception that must be dealt with in the code, either by catching it or by specifying a throws clause. Checked exceptions are all exceptions that are subclassed from Exception except RuntimeException. An unchecked exception is an exception that need not be dealt with programmatically. It includes RuntimeExceptions (and its subclasses) and Error and its subclasses. ==================================================================== Checked vs. unchecked exceptions There are two kinds of exceptions in Java, checked and unchecked, and only checked exceptions need appear in throws clauses. The general rule is: Any checked exceptions that may be thrown in a method must either be caught or declared in the method's throws clause. Checked exceptions are so called because both the Java compiler and the Java virtual machine check to make sure this rule is obeyed. Whether or not an exception is "checked" is determined by its position in the hierarchy of throwable classes. Figure 4 shows that some parts of the Throwable family tree contain checked exceptions while other parts contain unchecked exceptions. To create a new checked exception, you simply extend another checked exception. All throwables that are subclasses of Exception, but not subclasses of RuntimeException are checked exceptions.
156) How you can create dynamically servlet objects at the time of webapplication deploying?
157) What is the difference between function and procedure in oracle?
158) What is the difference between drop and truncate?
159) What is the difference between truncate and delete?
160) Suppose you are doing any actions on database but you system will not doing any actions on database? How you can know about this thing?( By starting logging information in a file)
161) Servlet are by defaulty single threaded or multiple threaded?
162) What is the syntax of jsp:usebean?
jspusebean syntax:
163) What is the difference between reqdis.forward(),jsp:forward?
jsp:forward is a Action tag in jsp which is used to forward the request from one page to other page . This is similar to requestDespatcher.forward.
In requestdespatcher forward ,only one request will be sent by the browser and it is processed by two servlets/jsps.
164)What is a view?
View in a Mvc pattern is containing the presentation logic.
We are using jsps as view in MVC architecture.
165) What is the difference between callable statements, prepare statements , createstatements?
callable statements: callable statements are used to retrieve the stored procedures from the database. ie., these statements are used when two or more sql statements are retrived over and over.
prepare statement: theser are precompiled statements which are stored in database. We are using these prepare statemnts if the same query is to be executed over and over.
statement: statement is used to execute single sql statement.
No comments:
Post a Comment