InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
In The Servlet 2.4 Specification Singlethreadmodel Has Been Deprecates, Why? |
|
Answer» Because it is not practical to have such model. Whether you SET isThreadSafe to true or false, you should take care of concurrent client requests to the JSP PAGE by synchronizing access to any SHARED objects DEFINED at the page level. Because it is not practical to have such model. Whether you set isThreadSafe to true or false, you should take care of concurrent client requests to the JSP page by synchronizing access to any shared objects defined at the page level. |
|
| 2. |
How Can You Store International / Unicode Characters Into A Cookie? |
|
Answer» One way is, before storing the COOKIE URLENCODE it. One way is, before storing the cookie URLEncode it. |
|
| 3. |
What's The Difference Between Forward And Sendredirect? |
|
Answer» 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. 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. |
|
| 4. |
What Are Context Initialization Parameters |
|
Answer» 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. 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. |
|
| 5. |
How Is Jsp Used In The Mvc Model |
|
Answer» 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. 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. |
|
| 6. |
What Is A Translation Unit? |
|
Answer» JSP page can include the contents of other HTML pages or other JSP files. This is DONE by using the include DIRECTIVE. When the JSP engine is presented with such a JSP page it is converted to ONE SERVLET class and this is called a translation unit, Things to remember in a translation unit is that page directives affect the WHOLE unit, one variable declaration cannot occur in the same unit more than once, the standard action jsp:useBean cannot declare the same bean twice in one unit. JSP page can include the contents of other HTML pages or other JSP files. This is done by using the include directive. When the JSP engine is presented with such a JSP page it is converted to one servlet class and this is called a translation unit, Things to remember in a translation unit is that page directives affect the whole unit, one variable declaration cannot occur in the same unit more than once, the standard action jsp:useBean cannot declare the same bean twice in one unit. |
|
| 7. |
What Are The Lifecycle Phases Of A Jsp? |
|
Answer» JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP engine does the following 7 phases. JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP engine does the following 7 phases. |
|
| 8. |
What Is Jsp? Describe Its Concept? |
|
Answer» 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. 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. |
|
| 9. |
How Servlet Differ From Jsp? |
|
Answer» Both Servlet and JAVA Server Pages are API which generate dynamic web content. A servlet is NOTHING but a java class which implements the interface to run within a web and on the other hand Java server pages is a bit complicated THING which contain a mixture of Java SCRIPTS, Java directives, Java elements and HTML. The main difference among both servlet and Java server pages is that JSP is document oriented and servlet on the other hand act LIKES a program. Both Servlet and Java Server Pages are API which generate dynamic web content. A servlet is nothing but a java class which implements the interface to run within a web and on the other hand Java server pages is a bit complicated thing which contain a mixture of Java scripts, Java directives, Java elements and HTML. The main difference among both servlet and Java server pages is that JSP is document oriented and servlet on the other hand act likes a program. |
|
| 10. |
What Are The Implicit Objects In Jsp? |
|
Answer» There are all total 9 implicit objects in JSP. Application interface refers to the web application’s interface whereas Session interface refers to the user’s session. Request interface refers to the PAGE which is currently REQUESTED whereas Response interface refers to the response which is currently made by the user. Config interface refers to the servlet configuration. Class like out, page, page Context and EXCEPTION refers to the output stream of the page, servlet instance of the page, ENVIRONMENT of the page, error handling respectively. There are all total 9 implicit objects in JSP. Application interface refers to the web application’s interface whereas Session interface refers to the user’s session. Request interface refers to the page which is currently requested whereas Response interface refers to the response which is currently made by the user. Config interface refers to the servlet configuration. Class like out, page, page Context and exception refers to the output stream of the page, servlet instance of the page, environment of the page, error handling respectively. |
|
| 11. |
How Jsp Calls A Stored Procedure? |
|
Answer» Java SERVER Pages possess all the characteristics of java and to call and have SIMILAR syntax to call a function. Functions and stored procedures of a DATABASE can be called by using the statement callable. Another way to call the stored procedure is by writing the JDBC code in between the TAG of scriptlet tab.write. Java Server Pages possess all the characteristics of java and to call and have similar syntax to call a function. Functions and stored procedures of a database can be called by using the statement callable. Another way to call the stored procedure is by writing the JDBC code in between the tag of scriptlet tab.write. |
|
| 12. |
How To Override The Lifecycle Methods Of Jsp? |
|
Answer» Lifecycle METHOD jspService() cannot be OVERRIDDEN within a JSP page however methods like jspInit() and jspDestroy() can be overridden within a JSP page. Method jspInit() is used for ALLOCATING resource while method jspDestroy() is used to free allocated resource. But it should be kept in mind that during the lifecycle of a Java SERVER Page both the method jsplnit() and jspDestroy() is EXECUTED once and are declared as JSP declarations. Lifecycle method jspService() cannot be overridden within a JSP page however methods like jspInit() and jspDestroy() can be overridden within a JSP page. Method jspInit() is used for allocating resource while method jspDestroy() is used to free allocated resource. But it should be kept in mind that during the lifecycle of a Java Server Page both the method jsplnit() and jspDestroy() is executed once and are declared as JSP declarations. |
|
| 13. |
What Is Declaration In Jsp? |
|
Answer» In JAVA Server pages Declaration is used to declare and DEFINE variables and methods that can be used in the Java Server Pages. The variable which is DECLARED is INITIALIZED once and it retain its value for every subsequent client request. In Java Server pages Declaration is used to declare and define variables and methods that can be used in the Java Server Pages. The variable which is declared is initialized once and it retain its value for every subsequent client request. |
|
| 14. |
How A Run - Time Application Is Handled In Jsp? |
|
Answer» In JSP the errorpage attribute of the PAGE is used as a directive to have uncaught run – time EXCEPTIONS and which is automatically forwarded to an page which processes the error. If an uncaught EXCEPTION is encountered while processing the REQUEST, then the BROWSER redirects to the JSP error page. In JSP the errorpage attribute of the page is used as a directive to have uncaught run – time exceptions and which is automatically forwarded to an page which processes the error. If an uncaught exception is encountered while processing the request, then the browser redirects to the JSP error page. |
|
| 15. |
State The Difference Between The Expression And Scriptlet? |
|
Answer» JSP, Expressions is USED to display the values of variable or to return the values by invoking the getter methods. However, JSP expressions begins with <> and does not have semicolon at the end of the expression. Scriptlet can contain variable, method or expressions that are valid within the PAGE scripting language. Within the scripting TAGS and page scripting language any valid OPERATIONS can be PERFORMED. JSP, Expressions is used to display the values of variable or to return the values by invoking the getter methods. However, JSP expressions begins with <> and does not have semicolon at the end of the expression. Scriptlet can contain variable, method or expressions that are valid within the page scripting language. Within the scripting tags and page scripting language any valid operations can be performed. |
|
| 16. |
Outline The Difference Between Java Server Page Forward And Servlet Forward Method? |
|
Answer» The only minor difference between both the METHODS is that Java Server page forward method can’t forward to another JSP page in another WEB application or CONTAINER whereas servlet forward method can do so. The only minor difference between both the methods is that Java Server page forward method can’t forward to another JSP page in another web application or container whereas servlet forward method can do so. |
|
| 17. |
What Are Custom Tags And Why It Is Needed? |
|
Answer» JSP tags are extended by creating a custom set of tags which is CALLED as tag library (TAGLIB). The page which uses custom tags declares taglib and uniquely NAMES, defines and associates a tag PREFIX to differentiate the USAGE of those tags. JSP tags are extended by creating a custom set of tags which is called as tag library (taglib). The page which uses custom tags declares taglib and uniquely names, defines and associates a tag prefix to differentiate the usage of those tags. |
|
| 18. |
How Cookies Is Deleted In Jsp? |
|
Answer» There are TWO ways by which the cookies can be DELETED in JSP. Firstly, by setting the setMaxAge() of the cookie CLASS to zero. And secondly by setting a timer in the HEADER file that is response. setHeader(expires {Mention the time} ATTRIBUTE), which will delete the cookies after that prescribed time. There are two ways by which the cookies can be deleted in JSP. Firstly, by setting the setMaxAge() of the cookie class to zero. And secondly by setting a timer in the header file that is response. setHeader(expires {Mention the time} attribute), which will delete the cookies after that prescribed time. |
|
| 19. |
Is It Possible By A Jsp Page To Process Html Form Data? |
|
Answer» Yes it is possible by SIMPLY OBTAINING the data from the FORM input via the request implicit OBJECT which lies with a scriptlet or expression but it doesn't require to implement any HTTP – PROTOCOL methods like goGet() or DOPOST() within the JSP page. Yes it is possible by simply obtaining the data from the FORM input via the request implicit object which lies with a scriptlet or expression but it doesn't require to implement any HTTP – Protocol methods like goGet() or doPost() within the JSP page. |
|
| 20. |
How Method Is Declared Within Jsp Page? |
|
Answer» Methods can be declared for USE within JSP page as DECLARATION and this method can be invoked within any other method which is declared or within JSP scriptlets or expressions. Direct access to the JSP implicit objects like REQUEST, response, session etc is forbidden within JSP methods but implicit Java server page variable is allowed to pass as PARAMETERS to the method which is declared. Methods can be declared for use within JSP page as declaration and this method can be invoked within any other method which is declared or within JSP scriptlets or expressions. Direct access to the JSP implicit objects like request, response, session etc is forbidden within JSP methods but implicit Java server page variable is allowed to pass as parameters to the method which is declared. |
|
| 21. |
Outline The Major Difference Between The Session And Cookie? |
|
Answer» SESSIONS are ALWAYS stored in the server side whereas COOKIES are always stored in the CLIENT side. Sessions are always stored in the server side whereas cookies are always stored in the client side. |
|
| 22. |
What Are The Steps Required In Adding A Jsp Tag Libraries? |
|
Answer» Create a TLD file and configure the required class Information. Create a TLD file and configure the required class Information. |
|
| 23. |
What Is The Page Directive Is Used To Prevent A Jsp Page From Automatically Creating A Session: |
|
Answer» <%@ PAGE SESSION="FALSE"> <%@ page session="false"> |
|
| 24. |
How Do I Use A Scriptlet To Initialize A Newly Instantiated Bean? |
|
Answer» A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically invoked when the specified bean is instantiated. Typically, the body will contain scriptlets or jsp:setProperty TAGS to initialize the newly instantiated bean, although you are not restricted to using those alone. The following example SHOWS the "today" property of the Foo bean INITIALIZED to the current date when it is instantiated. Note that here, we make use of a JSP expression within the jsp:setProperty action. A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically invoked when the specified bean is instantiated. Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the newly instantiated bean, although you are not restricted to using those alone. The following example shows the "today" property of the Foo bean initialized to the current date when it is instantiated. Note that here, we make use of a JSP expression within the jsp:setProperty action. |
|
| 25. |
What Are Advantages Of Jsp |
|
Answer» WHENEVER there is a change in the code, we dont have to recompile the jsp. it automatically does the COMPILATION. by using CUSTOM tags and tag libraries the LENGTH of the java code is reduced. whenever there is a change in the code, we dont have to recompile the jsp. it automatically does the compilation. by using custom tags and tag libraries the length of the java code is reduced. |
|
| 26. |
What Are Jsp Directives? |
|
Answer» • JSP directives are messages for the JSP engine. i.e., JSP directives serve as a message from a JSP page to the JSP CONTAINER and control the processing of the entire page. • JSP directives are messages for the JSP engine. i.e., JSP directives serve as a message from a JSP page to the JSP container and control the processing of the entire page. |
|
| 27. |
What Is Page Directive? |
|
Answer» • A page DIRECTIVE is to INFORM the JSP engine about the headers or facilities that page should get from the ENVIRONMENT. • A page directive is to inform the JSP engine about the headers or facilities that page should get from the environment. |
|
| 28. |
What Are The Attributes Of Page Directive? |
|
Answer» There are thirteen ATTRIBUTES defined for a page directive of which the important attributes are as follows: There are thirteen attributes defined for a page directive of which the important attributes are as follows: |
|
| 29. |
What Is The Include Directive? |
|
Answer» There are thirteen attributes defined for a page directive of which the importantattributes are as follows: There are thirteen attributes defined for a page directive of which the importantattributes are as follows: |
|
| 30. |
What Are The Jsp Standard Actions? |
|
Answer» • The JSP STANDARD ACTIONS affect the overall runtime behavior of a JSP page and also the response sent back to the client. • The JSP standard actions affect the overall runtime behavior of a JSP page and also the response sent back to the client. |
|
| 31. |
What Are The Standard Actions Available In Jsp? |
|
Answer» The standard actions available in JSP are as follows:
The standard actions available in JSP are as follows:
|
|
| 32. |
Differentiate Between Pagecontext.include And Jsp:include? |
|
Answer» The <jsp:INCLUDE> standard action and thepageContext.include() method are both used to include resources at runtime. However, thepageContext.include() method ALWAYS flushes the output of the CURRENT page before INCLUDING the other components, whereas<jsp:include> flushes the output of the current page only if the value = of FLUSH is explicitly set to true as follows: The <jsp:include> standard action and thepageContext.include() method are both used to include resources at runtime. However, thepageContext.include() method always flushes the output of the current page before including the other components, whereas<jsp:include> flushes the output of the current page only if the value = of flush is explicitly set to true as follows: |
|
| 33. |
What Is The Jsp:getproperty Action? |
|
Answer» The <jsp:getProperty> ACTION is USED to ACCESS the properties of a bean that was set using the <jsp:getProperty> action. The container converts the property to a String as follows:
Here, name is the id of the bean from which the property was set. The property attribute is the property to get. A user must CREATE or locate a bean using the <jsp:useBean> action before using the <jsp:getProperty> action. The <jsp:getProperty> action is used to access the properties of a bean that was set using the <jsp:getProperty> action. The container converts the property to a String as follows: Here, name is the id of the bean from which the property was set. The property attribute is the property to get. A user must create or locate a bean using the <jsp:useBean> action before using the <jsp:getProperty> action. |
|
| 34. |
What Is The Standard Action? |
|
Answer» The <JSP:param> standard action is used with <jsp:include> or <jsp:FORWARD> to pass parameter names and values to the target RESOURCE. The syntax of the <jsp:param> standard action is as follows: The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter names and values to the target resource. The syntax of the <jsp:param> standard action is as follows: |
|
| 35. |
What Are Scripting Elements? |
|
Answer» JSP scripting elements LET you insert Java code into the servlet that will be GENERATED from the current JSP page. There are three forms:
JSP scripting elements let you insert Java code into the servlet that will be generated from the current JSP page. There are three forms: |
|
| 36. |
What Is The Jsp:plugin Action ? |
|
Answer» This action lets you insert the BROWSER-specific OBJECT or EMBED element needed to specify that the browser RUN an applet using the Java PLUGIN. This action lets you insert the browser-specific OBJECT or EMBED element needed to specify that the browser run an applet using the Java plugin. |
|
| 37. |
What Are Jsp Declarations? |
|
Answer» As the name implies, JSP declarations are used to declare class VARIABLES and methods in a JSP page. They are initialized when the class is initialized. Anything defined in a declaration is available for the whole JSP page. A declaration BLOCK is enclosed between the <%! and %> tags. A declaration is not INCLUDED in theservice() METHOD when a JSP is TRANSLATED to a servlet. As the name implies, JSP declarations are used to declare class variables and methods in a JSP page. They are initialized when the class is initialized. Anything defined in a declaration is available for the whole JSP page. A declaration block is enclosed between the <%! and %> tags. A declaration is not included in theservice() method when a JSP is translated to a servlet. |
|
| 38. |
What Is A Jsp Expression? |
|
Answer» A JSP expression is used to WRITE an output without using the out.print statement. It can be SAID as a SHORTHAND representation for scriptlets. An expression is written between the <%= and %> TAGS. It is not required to END the expression with a semicolon, as it implicitly adds a semicolon to all the expressions within the expression tags. A JSP expression is used to write an output without using the out.print statement. It can be said as a shorthand representation for scriptlets. An expression is written between the <%= and %> tags. It is not required to end the expression with a semicolon, as it implicitly adds a semicolon to all the expressions within the expression tags. |
|
| 39. |
How Is Scripting Disabled? |
|
Answer» SCRIPTING is disabled by setting the scripting-invalid element of the deployment descriptor to TRUE. It is a sub element of JSP-property-group. Its valid values are true and false. The syntax for disabling scripting is as FOLLOWS: Scripting is disabled by setting the scripting-invalid element of the deployment descriptor to true. It is a sub element of jsp-property-group. Its valid values are true and false. The syntax for disabling scripting is as follows: |
|
| 40. |
What Is A Servlet ? |
|
Answer» SERVLET is a java program that runs INSIDE a web CONTAINER. servlet is a java program that runs inside a web container. |
|
| 41. |
What Is Servlet Context ? |
|
Answer» The servlet CONTEXT is an object that contains a information about the WEB application and container. Using the context, a servlet can log EVENTS, obtain URL references to resources, and set and store ATTRIBUTES that other servlets in the context can use. The servlet context is an object that contains a information about the Web application and container. Using the context, a servlet can log events, obtain URL references to resources, and set and store attributes that other servlets in the context can use. |
|
| 42. |
What Is Servlet Mapping? |
|
Answer» The servlet mapping defines an ASSOCIATION between a URL pattern and a servlet. The mapping is USED to MAP requests to SERVLETS. The servlet mapping defines an association between a URL pattern and a servlet. The mapping is used to map requests to Servlets. |
|
| 43. |
Difference Between Get And Post? |
|
Answer» In GET your entire form submission can be encapsulated in one URL, LIKE a hyperlink. query length is limited to 255 characters, not secure, faster, quick and easy. The DATA is submitted as part of URL. In POST data is submitted inside body of the HTTP request. The data is not visible on the URL and it is more secure. In GET your entire form submission can be encapsulated in one URL, like a hyperlink. query length is limited to 255 characters, not secure, faster, quick and easy. The data is submitted as part of URL. In POST data is submitted inside body of the HTTP request. The data is not visible on the URL and it is more secure. |
|
| 44. |
What Are The Different Ways For Session Tracking? |
|
Answer» COOKIES, URL rewriting, HTTPSESSION, Hidden FORM FIELDS. Cookies, URL rewriting, HttpSession, Hidden form fields. |
|
| 45. |
What Is Difference Between Custom Jsp Tags And Beans? |
|
Answer» Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are interpreted, and then group your tags into collections called tag libraries that can be used in any number of JSP files. To use custom JSP tags, you NEED to define three separate components: the tag handler class that defines the tag's behavior ,the tag library descriptor file that maps the XML element names to the tag implementations and the JSP file that uses the tag library. JavaBeans are Java utility classes you defined. BEANS have a standard format for Java classes. You use tags . Custom tags and beans accomplish the same goals -- encapsulating COMPLEX behavior into simple and accessible forms. There are several differences. Custom tags can manipulate JSP content; beans cannot. Complex operations can be reduced to a significantly simpler form with custom tags than with beans. Custom tags require QUITE a bit more work to SET up than do beans. Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page. Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions. Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are interpreted, and then group your tags into collections called tag libraries that can be used in any number of JSP files. To use custom JSP tags, you need to define three separate components: the tag handler class that defines the tag's behavior ,the tag library descriptor file that maps the XML element names to the tag implementations and the JSP file that uses the tag library. JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes. You use tags . Custom tags and beans accomplish the same goals -- encapsulating complex behavior into simple and accessible forms. There are several differences. Custom tags can manipulate JSP content; beans cannot. Complex operations can be reduced to a significantly simpler form with custom tags than with beans. Custom tags require quite a bit more work to set up than do beans. Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page. Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions. |
|
| 46. |
What Is The Difference Between Jsp And Servlets ? |
|
Answer» JSP is used mainly for PRESENTATION only. A JSP can only be HttpServlet that MEANS the only supported protocol in JSP is HTTP. But a servlet can support any protocol like HTTP, FTP, SMTP etc. JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only supported protocol in JSP is HTTP. But a servlet can support any protocol like HTTP, FTP, SMTP etc. |
|
| 47. |
What's A Better Approach For Enabling Thread-safe Servlets And Jsps? Singlethreadmodel Interface Or Synchronization? |
|
Answer» Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. If you ANTICIPATE your users to increase in the future, you may be better off implementing explicit synchronization for your shared data. The key HOWEVER, is to effectively minimize the amount of code that is synchronzied so that you take maximum advantage of MULTITHREADING. Also, note that SingleThreadModel is pretty resource intensive from the server\'s perspective. The most serious issue however is when the number of concurrent requests EXHAUST the servlet instance pool. In that case, all the unserviced requests are queued until something becomes free - which results in poor performance. Since the USAGE is non-deterministic, it may not help much even if you did add more memory and increased the size of the instance pool. Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. If you anticipate your users to increase in the future, you may be better off implementing explicit synchronization for your shared data. The key however, is to effectively minimize the amount of code that is synchronzied so that you take maximum advantage of multithreading. Also, note that SingleThreadModel is pretty resource intensive from the server\'s perspective. The most serious issue however is when the number of concurrent requests exhaust the servlet instance pool. In that case, all the unserviced requests are queued until something becomes free - which results in poor performance. Since the usage is non-deterministic, it may not help much even if you did add more memory and increased the size of the instance pool. |
|
| 48. |
Explain The Life-cycle Mehtods In Jsp? |
|
Answer» The generated servlet class for a JSP page implements the HttpJspPage INTERFACE of the javax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which inturn extends the Servlet interface of the javax.servlet package. the generated servlet class thus implements all the methods of the these three interfaces. The JspPage interface declares only two mehtods - jspInit() and jspDestroy() that must be implemented by all JSP page regardless of the client-server protocol. However the JSP specification has provided the HttpJspPage interfaec specifically for the JSp pages serving HTTP REQUESTS. This interface declares one method_jspService(). The jspInit()- The container calls the jspInit() to initialize te servlet INSTANCE.It is called before any other method, and is called only once for a servlet instance. The _jspservice()- The container calls the _jspservice() for each request, passing it the request and the response objects. The jspDestroy()- The container calls this when it DECIDES take the instance out of service. It is the last method called n the servlet instance. The generated servlet class for a JSP page implements the HttpJspPage interface of the javax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which inturn extends the Servlet interface of the javax.servlet package. the generated servlet class thus implements all the methods of the these three interfaces. The JspPage interface declares only two mehtods - jspInit() and jspDestroy() that must be implemented by all JSP page regardless of the client-server protocol. However the JSP specification has provided the HttpJspPage interfaec specifically for the JSp pages serving HTTP requests. This interface declares one method_jspService(). The jspInit()- The container calls the jspInit() to initialize te servlet instance.It is called before any other method, and is called only once for a servlet instance. The _jspservice()- The container calls the _jspservice() for each request, passing it the request and the response objects. The jspDestroy()- The container calls this when it decides take the instance out of service. It is the last method called n the servlet instance. |
|
| 49. |
What Are The Different Scope Valiues For The ? |
|
Answer» The different scope values for <JSP:useBean> are The different scope values for <jsp:useBean> are |
|
| 50. |
Difference Between Forward And Sendredirect? |
|
Answer» When you invoke a forward request, the request is sent to another resource ohe server, WITHOUT the client being informed that a different resource is going to process the request. This process occurs completly with in the web CONTAINER. When a sendRedirtect 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 completly 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. When you invoke a forward request, the request is sent to another resource ohe server, without the client being informed that a different resource is going to process the request. This process occurs completly with in the web container. When a sendRedirtect 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 completly 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. |
|