|
1. How is JSP used in the MVC model ? JSP is usually used for presentation in the MVC pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals with calling the model and the business classes which in turn get the data, this data is then presented to the JSP for rendering on to the client. 2. What’s the difference between forward and sendRedirect ? When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completely with in the web container And then returns to the calling method. When a sendRedirect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completely new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward. 3. What are context initialization parameters ? Context initialization parameters are specified by the in the web.xml file, these are initialization parameter for the whole application and not specific to any servlet or JSP. 4. What are the lifecycle phases of a JSP ? JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP engine does the following 7 phases. Page translation : page is parsed, and a java file which is a servlet is created. Page compilation : page is compiled into a class file Page loading : This class file is loaded. Create an instance : Instance of servlet is created jspInit() method is called _jspService is called to handle service calls _jspDestroy is called to destroy it when the servlet is not required.
5. What is a Expression ? Expressions are act as place holders for language expression, expression is evaluated each time the page is accessed. 6. What are the implicit objects ? List them. Certain objects that are available for the use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated servlet. The implicit objects are: - request
- response
- pageContext
- session
- application
- out
- config
- page
- exception
7. What is JSP ? Describe its concept. JSP is a technology that combines HTML/XML markup languages and elements of Java programming Language to return dynamic content to the Web client, It is normally used to handle Presentation logic of a web application, although it may have business logic.
|