Javafaq Bank
Javafaq Bank
Javafaq Bank
1)What is OOPs?
Ans: Object oriented programming organizes a program around its data,i.e.,objects and a set of well
defined interfaces to that data.An object-oriented program can be characterized as data controlling access
to code.
10)What is casting?
Ans: Casting is used to convert the value of one type to another.
11)How many ways can an argument be passed to a subroutine and explain them?
Ans: An argument can be passed in two ways. They are passing by value and passing by reference.
Passing by value: This method copies the value of an argument into the formal parameter of the
subroutine.
Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed
to the parameter.
15)What is UNICODE?
Ans: Unicode is used for internal representation of characters and strings and it uses 16 bits to represent
each other.
26)What is a package?
Ans: A package is a collection of classes and interfaces that provides a high-level layer of access
protection and name space management.
33) Can you have an inner class inside a method and what variables can you access?
Ans: Yes, we can have an inner class inside a method and final variables can be accessed.
38) What is multithreading and what are the methods for inter-thread communication and what is
the class in which these methods are defined?
Ans: Multithreading is the mechanism in which more than one thread run independent of each other
within the process.
wait (), notify () and notifyAll() methods can be used for inter-thread communication and these
methods are in Object class.
wait( ) : When a thread executes a call to wait( ) method, it surrenders the object lock and enters into
a waiting state.
notify( ) or notifyAll( ) : To remove a thread from the waiting state, some other thread must make a
call to notify( ) or notifyAll( ) method on the same object.
39) What is the class and interface in java to create thread and which is the most advantageous
method?
Ans: Thread class and Runnable interface can be used to create threads and using Runnable interface is
the most advantageous method to create threads because we need not extend thread class here.
44) What is daemon thread and which method is used to create the daemon thread?
Ans: 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.
45) Are there any global variables in Java, which can be accessed by other part of your program?
Ans: No, it is not the main method in which you define variables. Global variables is not possible because
concept of encapsulation is eliminated here.
46)What is an applet?
Ans: Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable
browser.
52) What is an event and what are the models available for event handling?
Ans: An event is an event object that describes a state of change in a source. In other words, event occurs
when an action is generated, like pressing button, clicking mouse, selecting a list, etc.
There are two types of models for handling events and they are:
a) event-inheritance model and b) event-delegation model
53) What are the advantages of the model over the event-inheritance model?
Ans: The event-delegation model has two advantages over the event-inheritance model. They are:
a)It enables event handling by objects other than the ones that generate the events. This allows a clean
separation between a component's design and its use.
b)It performs much better in applications where many events are generated. This performance
improvement is due to the fact that the event-delegation model does not have to be repeatedly process
unhandled events as is the case of the event-inheritance.
56)What is meant by controls and what are different types of controls in AWT?
Ans: Controls are components that allow a user to interact with your application and the AWT supports
the following types of controls:
Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components.
These controls are subclasses of Component.
66) What is a stream and what are the types of Streams and classes of the Streams?
Ans: A Stream is an abstraction that either produces or consumes information. There are two types of
Streams and they are:
Byte Streams: Provide a convenient means for handling input and output of bytes.
Character Streams: Provide a convenient means for handling input & output of characters.
Byte Streams classes: Are defined by using two abstract classes, namely InputStream and
OutputStream.
Character Streams classes: Are defined by using two abstract classes, namely Reader and Writer.
73) What are the types of JDBC Driver Models and explain them?
Ans: There are two types of JDBC Driver Models and they are:
a) Two tier model and b) Three tier model
Two tier model: In this model, Java applications interact directly with the database. A JDBC driver is
required to communicate with the particular database management system that is being accessed. SQL
statements are sent to the database and the results are given to user. This model is referred to as
client/server configuration where user is the client and the machine that has the database is called as the
server.
Three tier model: A middle tier is introduced in this model. The functions of this model are:
a) Collection of SQL statements from the client and handing it over to the database,
b) Receiving results from database to the client and
c) Maintaining control over accessing and updating of the above.
74) What are the steps involved for making a connection with a database or how do you connect to a
database?
Ans: a) Loading the driver : To load the driver, Class.forName( ) method is used.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
When the driver is loaded, it registers itself with the java.sql.DriverManager class as an
available database driver.
b) Making a connection with database : To open a connection to a given database,
DriverManager.getConnection( ) method is used.
Connection con = DriverManager.getConnection ("jdbc:odbc:somedb", "user", "password");
c) Executing SQL statements : To execute a SQL query, java.sql.statements class is used.
createStatement( ) method of Connection to obtain a new Statement object.
Statement stmt = con.createStatement( );
A query that returns data can be executed using the executeQuery( ) method of Statement. This
method executes the statement and returns a java.sql.ResultSet that encapsulates the retrieved data:
ResultSet rs = stmt.executeQuery("SELECT * FROM some table");
d) Process the results : ResultSet returns one row at a time. Next( ) method of ResultSet object can
be called to move to the next row. The getString( ) and getObject( ) methods are used for retrieving
column values:
while(rs.next( ) ) {
String event = rs.getString("event");
Object count = (Integer) rs.getObject("count");
CallableStatement -- To be used prepareCall( ) method for multiple SQL statements over and over
Interfaces Classes
Servlet Generic Servlet
ServletRequest ServletInputStream
ServletResponse ServletOutputStream
ServletConfig ServletException
ServletContext UnavailableException
SingleThreadModel
Javax.servlet.http contains:
Interfaces Classes
HttpServletRequest Cookie
HttpServletResponse HttpServlet
HttpSession HttpSessionBindingEvent
HttpSessionCintext HttpUtils
HttpSeesionBindingListener
85) What are the different servers available for developing and deploying Servlets?
Ans: a) Java Web Server b)JRun g) Apache Server
h) Netscape Information Server
i) Web Logic
86) How many ways can we track client and what are they?
Ans: The servlet API provides two ways to track client state and they are:
a) Using Session tracking and b) Using Cookies.
87) What is session tracking and how do you track a user session in servlets?
Ans: Session tracking is a mechanism that servlets use to maintain state about a series requests
from the same user across some period of time. The methods used for session tracking are:
a) User Authentication - occurs when a web server restricts access to some of its resources to only
those clients that log in using a recognized username and password
b) Hidden form fields - fields are added to an HTML form that are not displayed in the client's
browser. When the form containing the fields is submitted, the fields are sent back to the server
c) URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include
extra information. The extra information can be in the form of extra path information, added parameters
or some custom, server-specific URL change.
d) Cookies - a bit of information that is sent by a web server to a browser and which can later be read
back from that browser.
e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in
the session.maxresidents property
89) What are cookies and how will you use them?
Ans: Cookies are a mechanism that a servlet uses to have a client hold a small amount of state-
information associated with the user.
a) Create a cookie with the Cookie constructor: public Cookie(String name, String value)
b) A servlet can send a cookie to the client by passing a Cookie object to the addCookie() method of
HttpServletResponse: public void HttpServletResponse.addCookie(Cookie cookie)
c) A servlet retrieves cookies by calling the getCookies() method of HttpServletRequest:
public Cookie[ ] HttpServletRequest.getCookie( ).
90) Is it possible to communicate from an applet to servlet and how many ways and how?
Ans: Yes, there are three ways to communicate from an applet to servlet and they are:
a) HTTP Communication(Text-based and object-based)
b) Socket Communication
c) RMI Communication
(You can say, by using URL object open the connection to server and get the InputStream from
URLConnection object).
Steps involved for applet-servlet communication:
1) Get the server URL.-- URL url = new URL();
2) Connect to the host --- URLConnection Con = url.openConnection();
3) Initialize the connection -- Con.setUseCatches(false):
Con.setDoOutput(true);
Con.setDoInput(true);
4) Data will be written to a byte array buffer so that we can tell the server the length of the data.
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
5) Create the OutputStream to be used to write the data to the buffer.
DataOutputStream out = new DataOutputStream(byteout);
112) How do you pass data (including JavaBeans) to a JSP from a servlet?
(1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either "include" or
forward") can be called. This bean will disappear after processing this request has been completed.
Servlet:
request.setAttribute("theBean", myBean);
RequestDispatcher rd = getServletContext().getRequestDispatcher("thepage.jsp");
rd.forward(request, response);
JSP PAGE:
<jsp: useBean id="theBean" scope="request" class="....." />
(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session
(such as in individual user login) over a number of requests. This bean will disappear when the
session is invalidated or it times out, or when you remove it.
Servlet:
HttpSession session = request.getSession(true);
session.putValue("theBean", myBean);
/* You can do a request dispatcher here,
or just let the bean be visible on the
next request */
JSP Page:
<jsp:useBean id="theBean" scope="session" class="..." />
3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP
pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object
available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet
engine is shut down, or when you remove it.
Servlet:
GetServletContext(). setAttribute("theBean", myBean);
JSP PAGE:
<jsp:useBean id="theBean" scope="application" class="..." />
Component developers are free to focus on business logic, since containers provide services automatically
by interceding in component method calls. A simple set of callback interfaces are all that a developer
needs to implement to participate in container provided services.
A client's view of an Enterprise JavaBean remains the same regardless of the container it is deployed in.
Any container in which an Enterprise JavaBean is deployed presents the same interfaces to the client. This
extends to containers from different vendors, running against different servers and different databases, on
diverse systems on a network. This client transparency ensures wide scalability for multi-tier applications.
10)What methods are developers required to implement the Enterprise JavaBeans Architecture?
a)There are three categoriesof EJB methods.First, the bean implements methods to those in its home
interface containeing methods,second abean implements business logic methods corresponding to htose
prvided by its remote interface.Finally abean implements methods for interacting with the container.But
these methods are not intended for client access, they are hidden by the container.
11)What are the basic types of Enterprise JavaBeans?
a)There are two types of Enterprise beans- session beans and entity beans represending different types of
business logic abstactions.
Sesssion beans represent behaviors associated with client sessions,they are generally implemented to
perform a sequence of tasks with in the context of a transaction.A Session bean is a logical extension of
the client program, running process on the Clients behalf remotely on the server.
Entity beans reprsent specific data or collection of data, such as a row
in a relatiopnal database. Entity bean methods provided operations for action on the data represented by
the bean.An entity bean is persistent,it servives as long as its data remains in the database.
13)How does a Client find and connect to a specific enterprise bean write the coding?
a) Context ct=new InitialContext();
HaiHome home=(HaiHome)ct.lookup("hai");
HaiRemote remote=home.create();
then remote.Business methods..
14)What general services does a containe provide for an Enterprise JavaBean component?
a) A Container provides Enterprise JavaBeans Components with services of several types First it provides
services for lifecycle management and instance pooling, including creation,activation,passvation, and
destroy.Secod it interacts methods in a bean to enforce transction and security constraints.It enforce
policies and restrictions on bean instances, such as reentrance rules security polices , and some others.
19)What are types in SessionBeans?a) SessionBeans are mainly two types Stateless and Stateful
32)What are the transaction management benefits of the Enterprise JavaBeans architectur?
a)The Enterprise JavaBeans architecture provides automatic support for distributed transations in
component based applications.Such distributed transactions can automatically update data in multiple
databases.
41)Is is possible for an EJB client to marshall an object of class java.lang.Class to an EJB?
a)Technically yes, spec. compliant NO! "The enterprise bean must not attempt to query a class to
42)Is it possible to write two EJB's that share the same Remote and Home interfaces, and have
different bean classes? if so, what are the advantages/disadvantages?
a)Sharing interfaces might be possible, but not trivial.
If you deploy with Sun Deployment Tool 1.2.1 you will get a
java.lang.ClassCastException: MyBean2EJB_EJBObjectImpl ...
46)In CMP how can I define a finder method equivalent to a 'SELECT * FROM BANKS '
Weblogic 5.1.0 - Define the following Finder syntax in your weblogic-ejb-jar.xml deployment descriptor.
<finder>
<method-name>
<method-params> </method-params>
</method-name>
</finder>
b) It then checks the number of instance created in the container with the max beans in cache value,
if instances are less then container creates one new EJB instance
11)How does a container manage access from multiple transactions on an entity bean?
Containers manage multiple transactions in one of two ways. First, the container can instantiate multiple
instances of the bean and let the transaction management of the DBMS handle transaction processing
issues. Or, the container can acquire an exclusive lock on the instance's state in the database, and serialize
access from multiple transactions to this instance.
12)How do enterprise beans handle concurrent and loopback calls on entity beans?
Concurrent calls in the same transaction context on the same Enterprise JavaBean component are illegal
and may lead to unpredictable results. A bean can be marked as non-reentrant by its deployment
descriptor. This allows the container to detect and prevent illegal concurrent calls from clients. On the
other hand, some entity beans may require loopback calls: that is, calls where bean A is invoked, in turn
invoking bean B, which then invokes a method call on bean A. This kind of concurrency is tricky and is
best avoided.
TRANSACTION SUPPORT
14)What are the transaction management benefits of the Enterprise JavaBeans architecture?
The Enterprise JavaBeans architecture provides automatic support for distributed transactions in
component based applications. Such distributed transactions can atomically update data in multiple
databases, possibly even distributed across multiple sites. The Enterprise JavaBeans model shifts the
complexities of managing these transactions from the application developer to the container provider.
Does Enterprise JavaBeans allow alternatives to container-managed transactions?
In addition to container-managed transactions, an Enterprise JavaBean can participate in client-managed
and bean-managed transactions.
15)What transaction attributes do Enterprise JavaBean containers support?
A container supports the following values for the transaction attribute of an Enterprise JavaBean.
Not Supported :The bean runs outside the context of a transaction. Existing transactions are suspended for
the duration of method calls.
Required: Method calls require a transaction context. If one exists, it will be used; if none exists, one will
be created.
Supports :Method calls use the current transaction context if one exists, but don't create one if none exists.
Requires :New Containers create new transactions before each method call on the bean, and commit
transactions before returning.
Mandatory: Method calls require a transaction context. If none exists, an exception is thrown.
Never: Method calls require that no transaction context be present. If one exists, an exception is thrown.
18)What's the relationship between Enterprise JavaBeans component architecture and XML
technology?
The two technologies are complementary: Enterprise JavaBeans defines a standard for portable business
logic and XML technology defines a standard for portable data.
19)What's the relationship between the Enterprise JavaBeans architecture and JTA?
The Enterprise JavaBeans architecture is intended to conceal transactional complexities from the
component developer. Thus, developers and deployers writing to Enterprise JavaBeans architecture don't
need to access transaction management programmatically. However, in the case of bean- or client-
managed transactions, the developer can call methods of JTA to initiate and complete transactions. JTA
defines the Java programming language interfaces related to transaction management on the Java
platform, conformant with the OMG/OTS standard.
The JTA UserTransaction interface is intended to be provided by containers to enable both bean-managed
and client-managed transactions.
22)What new features are provided to support container-managed persistence for Entity beans?
The EJB 2.0 Specification defines a new mechanism for modeling persistent data with Entity beans, and a
new query language for Entity beans.
Features to support persistent data models include new abstract classes for both Entity beans and
dependent objects. These classes can be implemented to define complex models for persistent data. EJB
2.0 also defines new deployment descriptor elements to define the^Mabstract schema supported by a
bean. These allow the bean developer to specify the data model at development time, then allow a
container's deployment tools to automatically^Mgenerate the appropriate helper classes at deployment
time. This provides additional platform-independence while supporting a richer representation of the data
underlying an Entity bean.
In addition, EJB 2.0 defines the EJB QL, a query language that enables developers^Mto traverse the data
model of Entity beans independently of the language used^Mby the underlying database. ^MEJB QL uses
the abstract schema of entity beans, their dependent objects, and the^Mrelationships between these objects
for its data model. The syntax of EJB QL is similar to that of SQL.
EJB QL enables Bean Providers to write two types of query methods:
Finder methods in the home interface to enable entity bean clients to select specific entity objects.
Select methods which allow a bean internal access to related data without exposing^Mthat data directly to
the client.
23)How does EJB 2.0 improve support for interoperability between EJB containers and other J2EE
products?
The EJB 2.0 public draft specification includes requirements on EJB container/server providers which
enable interoperability for invocations on enterprise beans. These requirements enable communication
with J2EE clients including JavaServer Pages, Servlets, Application Clients as well as with enterprise
beans in other EJB containers. The goal of these features is to allow enterprise bean invocations to work
even when client components and enterprise beans are deployed in J2EE products from different vendors.
Support for interoperability between components includes transaction propagation, naming services and
security services.
The interoperability mechanisms in EJB 2.0 are based on the IIOP protocol from the Object Management
Group. The extensions supporting distributed transaction propagation, security (using SSL) and naming
service access are all based on OMG standards. J2EE container products may also use vendor-specific
protocols in addition to IIOP.
Is is possible for an EJB client to marshall an object of class java.lang.Class to an EJB?
Technically yes, spec. compliant NO! - refer to section 18.1.2 of the EJB 1.1 specification (page 273).
"The enterprise bean must not attempt to query a class to ...
Is it possible to write two EJB's that share the same Remote and Home interfaces, and have
different bean classes? if so, what are the advantages/disadvantages?
Sharing interfaces might be possible, but not trivial.
If you deploy with Sun Deployment Tool 1.2.1 you will get a java.lang.ClassCastException:
MyBean2EJB_EJBObjectImpl ...
Is it possible to specify multiple JNDI names when deploying an EJB?
No. To achieve this you have to deploy your EJB multiple times each
specifying a different JNDI name. Java:API:EJB Andrea Pompili ...
Is it possible to access a CORBA object from a EJB? I am using VisiBroker 4.0 for my CORBA
objects and J2EE 1.2.1 for my EJB.
These properties can be set on the commandline (using -Dorg. or using a file named orb.properties.
Java:API:EJB, Java:API:CORBA Robert Castaneda ...
How can we interact with COM/DCOM components from a EJB component ?
A list of tools that integrate Java with the Microsoft platform is available here. These tools can be used, as
long as they stay within the EJB specification requirements ...
Is it possible to stop the execution of a method before completion in a SessionBean?
Threads inside an EJB, refer to section 18.1.2 of the EJB 1.1 specification. One possible solution (that
requires coding) would be to set the transaction that the ...
a. Java
b. C
c. C++ - Answer
d. All
25. Which of the following attributes are compulsory with an <applet> tag?.
code,height & width.
26. What does 'CODEBASE' in an applet tag specify?.
Files absolute path.
29.Hostile Applets:Its an applet which when downloaded attempts to exploit your system's resources in an
inappropriate manner.It performs or causes you to perform an action which you would not otherwise care
to perform.
30.RemoteObjects: Objects that have methods that can be called accross virtual machines are Remote
Objects.An object becomes Remote by implementing Remote Interface.
59.What is hypertext?.
Sockets are endpoints of Internet Communication.They are associated with a host address and a port
address.Clients create client sockets and connect them to server sockets.
UDP is a connectionless protocol.
MIME(Multipurpose Internet Mail Extension) is a general method by which the content of different types
of Internet objects can be identified.
69. Awt Components and Swing Components can be inter-mingled in an Application - False
70. What are the features coming with JFC?.
(i) Pluggable Look-and-Feel
(ii) Accessibility API
(iii) Java 2D/API(JDK 1.2).
(iv) Drag and Drop Support(JDK 1.2)
75. When Swing components overlap with Heavyweight components, it is the latter that is on the top
- True
76. What are the components which are termed to be Heavy-weight, available in Light-weight
component?.
SQL
When database call is made using JDBC,the driver translates the request into vendor-specific API calls.
The database will process the requet and sends the results back through the Native API ,which will
forward them back to the JDBC dirver. The JDBC driver will format the results to conform to the JDBC
standard and return them to the application.
5. Explain about Type-3 driver ? When this type of driver is used ?
A. In this mechanism the flow of Execution will be
The Java Client Application sends the calls to the Intermediate data access server(jdbc driver server)
The middle tier then handles the requet using other driver(Type-II or Type-IV drivers) to complete the
request.
7. What are the Advantages & DisAdvantages of Type-2 ,Type-4 Drivers over JDBC-ODBC bridge
driver(Type-1)?
A. Type-2 & Type-4 are given
24.In which interface the methods commit() & rollback() are defined ?
A.java.sql.Connection interface
28.What is a Connection?
A. Connection is an interface which is used to make a connection between client and Database (ie opening
a session with a particular database).
29.what is the difference between execute() ,executeUpdate() and executeQuery() ? where we will
use them?
A. execute() method returns a boolean value (ie if the given query returns a resutset then it returns true
else false),so depending upon the return value we can get the ResultSet object (getResultset())or we can
know how many rows have bean affected by our query (getUpdateCount()).That is we can use this
method for Fetching queries and Non-Fetching queries.
Fetching queries are the queries which are used to fetch the records from database (ie which returns
resutset) ex: Select * from emp.
Non-Fetching queries are the queries which are used to update,insert,create or delete the records from
database ex: update emp set sal=10000 where empno=7809.
executeUpdate() method is used for nonfetching queries.which returns int value.
executeQuery() method is used for fetching queries which returns ResulSet object ,Which contains
methods to fetch the values.
t ------> is a Topic object that specifies the Topic we want to subscribe to.
name ---> is a String that indicates the name under which to maintain the Durable Subscribtion
to the specified topic.
messageselector --> is a String that defines selection criteria.
nolocal -------> is a boolean if it is true the Subscriber will not recive messages that were published
by the client application .
Non-DurableSubscription :-
-----------------------
Non-DurableSubscription will not recive the messages published when the client connection is not
active.
2. what is JTA ?
A. JTA (JAVA TRANSACTION API) is the API released by javasoft under J2EE.
It was released after the release of JTS .
5.what is DGC?
A.Distributed Garbage Collection is server side algorithm.It contains two methods those are dirty()and
clean().
24. How many requests can server fetch at a time? A. only one.
25.what is the JNDI [java Naming and Directory Interface] ? what its provides?
A. It provides standard java interface-to-naming events
29. DNS-URL:A. URL defining the DNS host to use for Addresses associated with JNDI urls
30.Authoritative:A. Value of true indicates that service access offers the most authoritative source
Questions on Servlets.
=====================
1) What is servlet?
Ans: Servlets are modules that extend request/response-oriented servers, such as java-enabled web
servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and
applying the business logic used to update a company’s order database.
3) What is the difference between an applet and a servlet?
Ans: a) Servlets are to servers what applets are to browsers.
b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.
11) Why do you need both GET and POST method implementations in Servlet?
Ans: A single servlet can be called from differenr HTML pages,so Different method calls can be possible.
19)What are the advantage of using Sessions over Cookies and URLReWriting?
Ans: Sessions are more secure and fast becasue they are stored at serverside. But Sessions has to be used
combindly with Cookies or URLReWriting for mainting the client id that is sessionid at client side.
Cookies are stored at client side so some clients may disable cookies so we may not sure that the
cookies which we are mainting may work or not but in sessions cookies are disable we can maintain
our sessionid using URLReWriting .
In URLReWriting we can't maintain large data because it leads to network traffic and access may be
become slow.Where as in seesions will not maintain the data which we have to maintain instead
we will maintain only the session id.
20) What is session tracking and how do you track a user session in servlets?
Ans: Session tracking is a mechanism that servlets use to maintain state about a series requests
from the same user across some period of time. The methods used for session tracking are:
a) User Authentication - occurs when a web server restricts access to some of its resources to only
those clients that log in using a recognized username and password
b) Hidden form fields - fields are added to an HTML form that are not displayed in the client’s
browser. When the form containing the fields is submitted, the fields are sent back to the server
c) URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include
extra information. The extra information can be in the form of extra path information, added parameters
or some custom, server-specific URL change.
d) Cookies - a bit of information that is sent by a web server to a browser and which can later be read
back from that browser.
e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in
the session.maxresidents property
28) What are the methods in HttpSession and use of those methods?
Ans:a) getCreationTime() Returns the time at which this session representation was created.
b)getId() Returns the identifier assigned to this session.
c)getLastAccessedTime() Returns the last time the client sent a request carrying the identifier assigned to
the session.
d)getSessionContext() Returns the context in which this session is bound.
e) getValue(String) Returns the object bound to the given name in the session's application layer data.
f)getValueNames() Returns an array of the names of all the application layer data objects bound into the
session.
g)invalidate() Causes this representation of the session to be invalidated and removed from its context.
h)isNew() A session is considered to be "new" if it has been created by the server, but the client has
not yet acknowledged joining the session.
j)putValue(String, Object) Binds the specified object into the session's application layer data with the
given name.
k)removeValue(String) Removes the object bound to the given name in the session's application layer
data.
29) How do you communicate between the servlets.
Ans: a)servlet chaning
b)Servlet context(RequestDespatcher interface)
30)Can you send the mail from a servlet ,if yes tell how?
Ans:yes.using mail API
40) What are the different servers available for developing and deploying Servlets?
Ans: a) JRun2.0--Allaire
b) Apache --jserv
c) jwsdk2.0 --sun
d) servletexec
e) Tomcat webserver--tomcat
41) Is it possible to communicate from an applet to servlet and how many ways and how?
Ans: Yes, there are three ways to communicate from an applet to servlet and they are:
a) HTTP Communication(Text-based and object-based)
b) Socket Communication
c) RMI Communication
(You can say, by using URL object open the connection to server and get the InputStream from
URLConnection object).
Steps involved for applet-servlet communication:
step: 1 Get the server URL.
URL url = new URL();
step: 2 Connect to the host
URLConnection Con = url.openConnection();
step: 3 Initialize the connection
Con.setUseCatches(false):
Con.setDoOutput(true);
Con.setDoInput(true);
step: 4 Data will be written to a byte array buffer so that we can tell the server the length of the data.
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
step: 5 Create the OutputStream to be used to write the data to the buffer.
DataOutputStream out = new DataOutputStream(byteout);
Ans: JSP pages are focused around HTML (or XML) with Java codes and JSP tags inside them. When a
web server that has JSP support is asked for a JSP page, it checks to see if it has already compiled the
page into a servlet. Thus, JSP pages become servlets and are transformed into pure Java and then
compiled, loaded into the server and executed.
Servlets:
Ans:You might have used servlet to servlet communication by using servletcontext methods like
getServlet(),getServlets() which are depricated and returns null from new release that is from
servlet2.1 API.
Standalone ServletEngine: A standalone engine is a server that includes built-in support for servlets.
Add-on ServletEngine: Its a plug-in to an existing server.It adds servlet support to a server that was not
originally designed with servlets in mind.
Embedded ServletEngine: it is a lightweight servlet deployment platform that can be embedded in another
application.that application become true server.
50)what is httptunneling?
ans: it is mechanism of performing both write and read operations using http protocol.it is extending
the functionality of http protocol.