Top Servlets Interview Questions :: ALLInterview.com http://www.allinterview.com Top Servlets Interview Questions en-us what is the difference between Servlet and JSP?Advantage of JSP over http://www.allinterview.com/showanswers/10953.html . The main difference between them is, In servlets both the presentation and business logic are place it together. Where as in jsp both are saparated by defining by java beans . In jsp's the overall code is modulated so the developer w Difference between Include, Forward and sendRedirect in Servlet? http://www.allinterview.com/showanswers/10954.html Response.sendRedirect () This function is used, when we want to redirect the client request to some other site (i.e out of our context) or when ever we want to redirect errors. If you are using sendRedirect (), then it will be visible to the What is ServletContext() and what is its use? http://www.allinterview.com/showanswers/2442.html Assume that ServletContext is shared momeroy for all servelts which are existed in a web application, we can place an object on to the servletcontext, and that can uses all other servlets which are exited in the web application. How do you pass the data from one servlet to another servlet? http://www.allinterview.com/showanswers/6848.html Using Request Dispatcher, you can send the values and forward to another page. ServletContext.getRequestDispatcher(); reqDispatcher.forward(req,res) Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the What is the difference between servlet config and servlet context. http://www.allinterview.com/showanswers/28139.html Servlet config is a private area for every servlet.Any variable stored there is accessible to only that servlet while sevlet context is a shared area for every servlet in an application.In an aaplication every servlet can access the variable What is Single Threaded Model in Servlets? Explain this with an exam http://www.allinterview.com/showanswers/1601.html Single Thread Model ensures that servlet handles only one request at a time.When YOUR CLASS IMPLEMENTS THIS INTERFACE WE ARE GUARENTEED THAT no two threads run simultaneously in service() method. this is a marker interface which contains no me How to make servlet thread safe? http://www.allinterview.com/showanswers/4920.html There are situations where we want to protect your servlet member variables from being modified by different clients.In this case you can have your servlet by implementing the marker interface SigleThreadModel. Everytime a client makes reque What is difference between Forward() and sendRedirect() methode? http://www.allinterview.com/showanswers/10790.html In the case of forward() the server will redirect to the next page but in the case of sendRedirct() the server will inform the browser to redirect the url to the next page. How to run a servlet program? http://www.allinterview.com/showanswers/2388.html We have to Make a WEB-INF folder and under it classes folder. In WEB-INF we have to write web.xml . Our compled servelet class file should be stored in classes folder. Make a war file using jar & deploy in Web. can i call destroy() method in init() method of servlet http://www.allinterview.com/showanswers/23275.html yes, u can call destroy() method in init() of Servlet. but calling destroy() in this way doesnt unload servlet from servlet container. Which method the Servlet container call to create the instance of th http://www.allinterview.com/showanswers/16906.html servlet container creates the init() method how can we create object to a class in a jsp file? http://www.allinterview.com/showanswers/36659.html use the page import tag to import ur class and execute methods of the class < % @ page import = packageName.Classname %> <% ImportedClass object = new ImportedClass(); object.executeMethods(); %> Please check for some docu we cant Override Jsp Service method?Why? http://www.allinterview.com/showanswers/36658.html _jspService() method will be written by the container hence any methods which are not to be overridden by the end user are typically written starting with an '_'. This is the reason why we don't override _jspService() method in a Can we override the ActionServlet? http://www.allinterview.com/showanswers/6897.html Yes we can modify the functionality of Action Servlet. to do this we have to extend the RequestProcessor class and overwrite the processPreprocess method. and then add following tag in Struts-config.xml <processor className="org.abc.co What is the use of RequestDispatcher in servlet? http://www.allinterview.com/showanswers/68876.html RequestDispatcher is used to connect to another webresource with in the same context. RequestDispatcher rd=ServletContext.getRequestDispatcher("url of resource"); rd.forward(req,res);----used to forward to another resource. rd.includ