Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Features

Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Servlet Interview Questions - Page 2

                         

Question: What are the lifecycle methods of Servlet?
Answer:
The interface javax.servlet.Servlet,  defines the three life-cycle methods. These are:
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
The container manages the lifecycle of the Servlet. When a new request come to a Servlet, the container performs the following steps.
1. If an instance of the servlet does not exist, the web container
    * Loads the servlet class.
    * Creates an instance of the servlet class.
    * Initializes the servlet instance by calling the init method. Initialization is covered in Initializing a Servlet.
2. The container invokes the service method, passing request and response objects.
3. To remove the servlet, container finalizes the servlet by calling the servlet's destroy method.

Question: What are the type of protocols supported by HttpServlet?
Answer:
It extends the GenericServlet base class and provides an framework for handling the HTTP protocol. So, HttpServlet only supports HTTP and HTTPS protocol.

Question: What are the directory Structure of Web Application?
Answer:
Web component follows the standard directory structure defined in the J2EE specification. 

Directory Structure of Web Component
 /
   index.htm, JSP, Images etc..
  Web-inf
   web.xml
   classes
         servlet classes
   lib
         jar files

Question: What is ServletContext?
Answer:
ServletContext is an Interface that defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)

Question: What is meant by Pre-initialization of Servlet?
Answer:
When servlet container is loaded, all the servlets defined in the web.xml file does not initialized by default. But the container receives the request it loads the servlet. But in some cases if you want your servlet to be initialized when context is loaded, you have to use a concept called pre-initialization of Servlet. In case of Pre-initialization, the servlet is loaded when context is loaded. You can specify <load-on-startup>1</load-on-startup>
in between the <servlet></servlet> tag.

Question: What mechanisms are used by a Servlet Container to maintain session information?
Answer:
Servlet Container uses Cookies, URL rewriting, and HTTPS protocol information to maintain the session.

Question: What do you understand by servlet mapping?
Answer:
Servlet mapping defines an association between a URL pattern and a servlet. You can use one servlet to process a number of url pattern (request pattern). For example in case of Struts *.do url patterns are processed by Struts Controller Servlet.

Question: What must be implemented by all Servlets?
Answer:
The Servlet Interface must be implemented by all servlets.

Question: What are the differences between Servlet and Applet?
Answer:
Servlets are server side components that runs on the Servlet container. Applets are client side components and runs on the web browsers. Servlets have no GUI interface.

Question: What are the uses of Servlets?
Answer: *
Servlets are used to process the client request.
               * A Servlet can handle multiple request concurrently and be used to develop high performance system
               * A Servlet can be used to load balance among serveral servers, as Servlet can easily forward request.

Question:  What are the objects that are received when a servlets accepts call from client?
Answer: The objects are ServeltRequest  and
ServletResponse . The ServeltRequest encapsulates the communication from the client to the
server. While ServletResponse encapsulates the communication from the Servlet back to the client.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

7 comments so far (
post your own) View All Comments Latest 10 Comments:

iam working on lims and retail java domain , i need latest questions and answers on struts, spring jsp servelts .

sincerely,

hema

Posted by hemalatha on Thursday, 05.1.08 @ 20:06pm | #58313

topics are good mentions

Posted by Ranjeet kumar on Saturday, 12.15.07 @ 17:06pm | #42494

I need nice urls in struts 2, can somebody help me?
i mean something like modrewrite in php.

Thank you very much

Posted by Winsik on Thursday, 07.5.07 @ 14:45pm | #20764

we want interview questions in linux

Posted by veeanagoud on Saturday, 06.2.07 @ 16:47pm | #18022

struts questions and answers are nice
but please increase the content for each question and give appropriate url's at the answer for better answer

Posted by venkateswarlu on Tuesday, 05.29.07 @ 15:24pm | #17634

i want to diff bet doget and dopost

Posted by pankaj khare on Tuesday, 02.27.07 @ 00:06am | #9729

All the above interview quetions and answers are very good. As per my knowledge they are very much helpful to the candidates who searching for jobs.

Thans®ards
Narahari

Posted by Narahari Bhadreshwar on Saturday, 02.3.07 @ 12:15pm | #5622

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.