Monday, May 24, 2010

latest jsp interview question

jsp - API package : javax.servlet.jsp
-------------------------------------
a. interface
1. HttpJspPage
It's extend JspPage. It have one method _jspService(req,res)
2. JspPage
It's extend javax.servlet.Servlet
It have two method jspDestroy(),jspInit()

b. Classes
1. ErrorData
2. Jsp Context
3. JpsEngineInfo
4. JspFactory
5. JspWrite
6. PageContext
c. Exception
JspException
JspTagException
SkipPageExceptiom
----------------------------------------------------------------------------------------------

JSP Life Cycle

If an instance of the JSP page's servlet does not exist, the container:

    1. Loads the JSP page's servlet class
    2. Instantiates an instance of the servlet class
    3. Initializes the servlet instance by calling the jspInit method
  1. Invokes the _jspService method, passing a request and response object. Don't Overridden.

3. If the container needs to remove the JSP page's servlet, it calls thejspDestroy method.



Question: What are implicit Objects available to the JSP Page?

Answer: Implicit objects are the objects available to the JSP page. These objects are created by Web container and contain information related to a particular request, page, or
application.
The JSP implicit objects are:



Variable
Class
Description
application
javax.servlet.ServletContext
The context for the JSP page's servlet and any Web components contained in the same application.
config
javax.servlet.ServletConfig
Initialization information for the JSP page's servlet.
exception
java.lang.Throwable
Accessible only from an error page.
out
javax.servlet.jsp.JspWriter
The output stream.
page
java.lang.Object
The instance of the JSP page's servlet processing the current request. Not typically used by JSP page authors.
pageContext
javax.servlet.jsp.PageContext
The context for the JSP page. Provides a single API to manage the various scoped attributes.
request
Subtype of javax.servlet.ServletRequest
The request triggering the execution of the JSP page.
response
Subtype of javax.servlet.ServletResponse
The response to be returned to the client. Not typically used by JSP page authors.
session
javax.servlet.http.HttpSession
The session object for the client.

shaninfotech: Ajax Interview Question


All interview question given link
shaninfotech: Ajax Interview Question



Ajax Interview Question

1. What is Ajax?
-----------------
Asynchornized javascript and XML. It is used to retrive the data without refresh the page
or reloading page dynamically.

2. What type of status and readystate avaliable in Ajax?
--------------------------------------------------------
a. Ready state
0 - Request is not initilized
1 - Server connection establized (loading)
2 - Request Received (loaded)
3 - Processing Request (Interactive)
4 - Request Finished and response is ready (complete)

b. status
200 code - ok
404 code - page not found

3. XMLHttpRequest Object
----------------------------
It is used to exchange the data with server behind the page

New version Syntax
==================
xmlhttp=new XMLHttpRequest();

old version syntax
===================
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

a. XMLHttpRequest object have two methods:

1. open(method,url,async)
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false (synchronous)

2.send(string)
Sends the request off to the server.
string: Only used for POST requests

b. XMLHttpRequest object Attribute
readyState the code successively changes value from 0 to 4 that means for "ready".
status 200 is OK
404 if the page is not found. responseText holds loaded data as a string of characters.
responseXml holds an XML loaded file, DOM's method allows to extract data. onreadystatechange property that takes a function as value that is invoked when the readystatechange event is dispatched.

4. Server Response
================
To get the response from a server, use the responseText or responseXML property of the XMLHttpRequst object.
a. responseText
document.getElementById("resultDiv").innerHTML=xmlhttp.responseText;
b. responseXML
xmlDoc=xmlhttp.responseXML;


Monday, May 10, 2010

Collection Interview Question

Difference between Hashmap and Hash table
1. Hashtable is sysnchronized but hash map is not thread safe.
2. Hashtable is not allow the null value and null key but hashmap is allow one null key and multiple null values.
3. HashMap retrieval is not in order (random). HashTable provide ordered retrieval.
4. In HashTable you can change the iteration but in the case of HashMap you can change the iteration but you will get a sjava.util.ConcurrentModificationException.

Difference between Vector and ArrayList? What is the Vector class?
Vector is synchronized whereas ArrayList is not. The Vector class provides the capability to implement a growable array of objects.
ArrayList and Vector class both implement the List interface. Both classes are implemented using dynamically resizable arrays, providing fast random access and fast traversal.
In vector the data is retrieved using the elementAt() method while in ArrayList, it is done using the get() method. ArrayList has no default size while vector has a default size of 10.

What is difference between array & arraylist?
An ArrayList is resizable, where as, an array is not. ArrayList is a part of the Collection Framework. We can store any type of objects, and we can deal with only objects. It is growable. Array is collection of similar data items. We can have array of primitives or objects. It is of fixed size. We can have multi dimensional arrays.
Array: can store primitive ArrayList: Stores object only
Array: fix size ArrayList: resizable
Array: can have multi dimensional
Array: lang ArrayList: Collection framework

Wednesday, May 5, 2010