Thursday, May 8, 2008

JSP Servlet J2EE Questions 5

21: Explain the directory structure of a web application.
A: The directory structure of a web application consists of two parts.
A private directory called WEB-INF
A public resource directory which contains public resource folder.

WEB-INF folder consists of
1. web.xml
2. classes directory
3. lib directory

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

23: 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.

24: 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.

25: 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.

1 comment:

Anonymous said...

Hi,

Get some more java interview questions on:
http://www.interviewhelper.org

Useful Information