Sponsored Links

Ad by Google
We know that while preparing for an interview there are lots of things needs to keep in your mind, and for freshers not easy to cover all the questions of Core Java, Servlet, JSP, Database, Aptitude, Algorithm etc. So we have planned to design few very popular interview question askeds in an interview for freshers on different series based on there priority and of course priority start from series 1. In our previous post we have listed very popular 20 Core Java basic interview questions for freshers. Friends don't worry we will post maximum number of interview questions on JSP Servlet but, started from very popular and most respective questions.

JSP Servlet Interview Questions For Freshers Series 1

1. What is the life cycle of Servlet?
Yes, this is very popular interview question and interviewer expect from you to at least list down the process involved while serving request for a Servlet. Well, Servlet life cycle is managed by Servlet Container and javax.servlet.Servlet interface defines three methods as a life cycle method of Servlet and those are listed below.
  1. void init(ServletConfig config)
  2. void service(ServletRequest req, ServletResponse res)
  3. void destroy()
When Servlet container received a request for a Servlet below are the steps involved.
  • Loading Servlet Class
  • Creating an Instance of Servlet
  • Calling the Servlet's init() method
  • Calling the Servlet's service() method
  • Calling the Servlet's destroy() method.
First three point executed only once at first time.

2. What is a deployment descriptor?
Well, Deployment descriptor is an entry point for any web application, and it refers to a configuration file for the web application. Which is also known as web.xml, it's all about how components of your web application to be deployed on your server/engine. The web.xml file must be placed inside WEB-INF subdirectory at the web application root. In web.xml we will map URLs to our Servlets.

3. What is the <load-on-startup>
The <load-on-startup> tag is optional tag in web.xml file. The tag is define inside Servlet tag only. The optional content of this element must be a positive integer indicating the order in which the Servlet should be loaded. Priorities start from lower integer, lower integers are loaded before higher integers for example if you pass values as 1,2,3.. in respective Servlets. Server will starts initialization of Servlet from 1,2,3.. If no value is specified, or if the value specified is not a positive integer, then Server can load the Servlet in any order during application startup. For more on load on startup with example

4. What is JSESSIONID and when it gets created?
We all know that HTTP is stateless protocol and it does not maintain the state of previous request. Means our server/container will not maintain the conversational states between requests. That's why few session management mechanisms are used like Cookies, HTTPSession etc.
JSESSIONID is one of them, I mean JSESSIONID is a cookies generated by our underlying server/container and used for session management in web application.
JSESSIONID is created when server/container first time received a request for accessing a web application. By default cookie used as session management. Here is an example of URL appending with JSESSIONID "https://mybank.com/corp/HomeController;jsessionid=00004VhLTrSQ-IIp8FnwlKA_LmT".

5. Can you list down the implicit Objects of JSP? Or What are the implicit Objects in JSP?
Yes, Interviewer wants you to list down all implicit object of JSP, and those are listed below.
  • out
  • request
  • response
  • session
  • application
  • config
  • page
  • pageContext
  • exception

6. Is it possible to use constructor, instead of init() method? Yes/No
Of course Yes.

7. What is the difference between URL encoding and URL rewriting?
Well both URL encoding and URL rewriting is totally different to each other there is no any similarities between them, URL rewriting is one of the way of managing the session in web application whereas URL encoding is a concept to replace some character of URL string with some special characters like %5000Bro%.

8. How to call one Servlet from another Servlet
You can call one Servlet from another Servlet using forward method of RequestDispatcher, below is the syntax of calling another Servlet.
RequestDispatcher rd = request.getRequestDispatcher("anotherServlet");
9. What are the different mechanisms to maintain Session in Servlet
Well four different mechanisms to maintain Session in Servlet and those are listed below.
  1. Cookie
  2. URL Rewriting
  3. HTTPSession
  4. Hidden Form Field
10. How many types of directive tags are in JSP?
Of course three,
  • @page
  • @include
  • @taglib

We have end here JSP Servlet Interview Questions For Freshers Series 1, here is our next series JSP Servlet Interview Questions For Freshers Series 2.
Friends you can also share your interview experience or improved answer of the questions with us, we will post your questions/answer on our interview question list.

Sponsored Links


  1. Very good post. its very beneficial to All. Need a latest Job opening updates. Visit Here :)

  2. Thank U for this nice blog, It's very beneficial for Freshers. Find More Job Vacancies here - Visit Here :)

  3. Excellent post!!! Your article helped to under the future of java development. Being an open source platform, java is integrated in most of the software development industries to create rich featured applications. Java Training in Chennai

  4. Excellent blogs.We have to learning that the lot new information.I will be like this information.

    Informatica Training in Chennai

    1. Thanks Vignesh, Keep visiting definitely you will find something new.

  5. awesome interview question . it is very full my interview times . thanks to sharing Selenium Training in Chennai || Web Designing Training in Chennai

  6. Learned something new . i am a newbie hope it will work for me! thanks..

    Cloud Computing Training in Chennai || ios Training in Chennai

  7. This tutorial post highlights the important difference between JSP and Servlet technologies. ... Show Navigation Hide Navigation ... Servlet and JSP are the two key Java server side technologies that are building blocks for ... please send a mail to krishnas at javabeat.net...
    Web Designing Course in Chennai

  8. What are different types of comments in JSP? ..... a collection or escape HTML tags to show them like text in response. Vmware Training in Chennai

  9. Thank you for this list, I found a lot of interesting things. I also learn some advance about iOS
    iOS Training in Chennai