- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
Servlet Interview Questions & Answers - Learning Mode

Servlet Interview Questions & Answers - Learning Mode

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. A servlet is a small program that runs on a server. The term was coined in the context of the Java applet, a small program that is sent as a separate file along with a Web (HTML) page. Java servlets are becoming increasingly popular as an alternative to CGI programs. The biggest difference between the two is that a Java applet is persistent.

Try Servlet Interview Questions & Answers - Exam Mode

1 2 3 4 5 6 7 8 9 10 Next

Sort By : Latest First | Oldest First | By Rating

Servlet Interview Questions & Answers - Learning Mode
Try Servlet Interview Questions & Answers - Exam Mode
Question: Difference between single thread and multi thread model serv

Answer: Typically, a servlet class is instantiated the first time it is invoked. The same instance will be used over several client requests, so all members that are declared in that servlet are shared accross clients.

That is what is meant by multi threaded model, multiple clients that access the same instance. There are situations where you want to protect your servlet member variables from being modified by different clients.

In this case, you can have your servlet implement the marke Source:
Question: What are the uses of Servlets?

Answer: A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to support systems such as on-line conferencing. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers that mirror the same content, and to partition a single logical service over several servers, according to task. Source:
Question: Difference between application server and web sever?

Answer: Web server serves pages for viewing the web browser( i.e HTML,JSP,ASP etc.)using http protocol. While application server handles business logic,such as transaction processing,messaging ,resource pooling, security and messaging etc.Both are accessing via the http request, so from the client view point there no much difference. Source:
Question: Why init is used and not constructor for servlets initialization?

Answer: The original reason for init() was that ancient versions of Java couldn?t dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won?t have access to a ServletConfig or ServletContext. Source:
Question: What is the servlet life cycle?

Answer: Each servlet has the same life cycle:
A server loads and initializes the servlet (init())
The servlet handles zero or more client requests (service())
The server removes the servlet (destroy()) (some servers do this step only when they shut down). Source:
Question: What is difference between servlet and ASP?

Answer: Platform and Server IndependenceJSP technology adheres to the Write Once, Run AnywhereTM philosophy of the JavaTM architecture. Instead of being tied to a single platform or vendor, JSP technology can run on any Web server and is supported by a wide variety of tools from multiple vendors.Open Development Process, Open SourceWorking with Sun in the JSP effort are authoring tool vendors (such as Macromedia), container companies (such as Apache and Netscape), end users, consultants, and others.The Source:
Question: Is servlet is used to create a dynamic webpage or Static webpage or both?

Answer: Yes both servlet is used to create a static and dynamic webpage,it also create a static webpage using serverside include it is .shtml extension,and so servlet is flexible character. Source:
Question: Can I invoke a JSP error page from a servlet?

Answer: Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to create a request dispatcher for the JSP error page, and pass the exception object as a javax.servlet.jsp.jspException request attribute. However, note that you can do this from only within controller servlets.

If your servlet opens an OutputStream or PrintWriter, the JSP engine will throw the following translation error:

java.lang.IllegalStateException: Cannot forward a Source:
Question: What is the actual difference between MVC and MVC Model2

Answer: MVC1, is architecture which does not include struts frame work in it, whereas in case of MVC2 it includes struts frame work.MVC1 is called model1 and MVC2 is called model2. Source:
Question: How can a web container know whether cookies are accepted or not accepted by the browser

Answer: The only way to know for sure is to set a cookie on a response, and see if
it comes back on the following request. You have absolutely no clue from
looking just at the current request. Just as an example, I run Netscape
6, configured to warn me every time about accepting a cookie -- so you
can't even look at the User-Agent header and predict whether *I* am going
to accept your cookie or not.

This is exactly what the servlet container does for you for session IDs,
a Source:
Question: Types of Servlets?

Answer: Servlets must implement the interface javax.servlet.Servlet. There are two main types of servlets:

Generic servlets extend javax.servlet.GenericServlet. Generic servlets are protocol independent, meaning that they contain no inherent support for HTTP or any other transport protocol.

HTTP servlets extend javax.servlet.HttpServlet. These servlets have built-in support for the HTTP protocol and are much more useful in an Browser environment
Question: What is pure servlet?

Answer: Pure servlet means we create any java objets that is implemented from javax.servler.Servlet interface.

Question: How to integare struts and hibernate

Answer: The Hibernate core provides optional components for certain common integration scenarios, including integration with JTA, JNDI-bound datasources, JMX, JCA, and the transaction managers of all popular application servers. In addition, some frameworks like Spring and Keel ship with built-in Hibernate support, and plugin support is available for others including Tapestry, Apache Avalon, and PicoContainer. JBoss Application Server features special support for Hibernate archive deploymentand integrat Source:
Question: What is the need of super.init(config) in servlets?

Answer: Basically super.init() method should be used whenever u are overriding the init method....else i dont think there is any necessity..... Source:
Question: What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext?

Answer: We can give relative URL when we use ServletRequest and not while using ServletContext. Source:
Question: What are the differences between GET and POST service methods?

Answer: Get
By using Get method in Session managment such as URL-rewriting we cannot get the data sent by URL-rewriting
You can use post method without worrying about URL-rewriting. Source:
Question: What is ActionMapping ?

Answer: In action mapping we specify action class for particular url ie path and diffrent target view ie forwards on to which request response will be forwarded. We also specify to which page control should go if there is validation error for ex input property of <action>. It is also specified which form bean will correspond to action


<action path="/a" type=myclasse.A name="myForm">

<forward name="succes" path="/success.jsp"/>

<fo Source:
Question: How we can check in particular page the session will be alive or not?

Answer: U can use request.getSession(false); method in HttpServletRequest interface.It returns the HttpSession associated with this request or null if the request has no valid session. Source:
Question: What is the correct syntax for removing ActionMessages from the session context?

Answer: Action.saveErrors(session, null);
Question: Whats meant by struts?how to use struts in IBM websphere appli. ?
and how to managed with struts?(plz answer simply just an intro. don't go very deep)


1 2 3 4 5 6 7 8 9 10 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.031006 Seconds