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. |
What is a JSP Declaration? |
|
Answer» The TAGS used in declaring variables are called JSP Declaration tags. These are used in declaring FUNCTIONS and variables. They are enclosed in <%!%> tag. Following is the syntax for JSP Declaration: <%@page contentType=”text/html” %><html><body><%!int a=0;private int getCount(){a++;RETURN a;}%><p>Values of a are:</p><p><%=getCount()%></p></body></html> |
|
| 2. |
What is MVC in JSP? |
|
Answer» In MVC,
It is an architecture that separates business LOGIC, presentation, and data. In this, the flow STARTS from the view layer, where the request is raised and processed in the controller layer. This is then SENT to the model layer to INSERT data and get back the success or failure message. |
|
| 3. |
What is the JSP Scriptlet? |
|
Answer» The JSP Scriptlet tag allows you to write Java code into a JSP file. The JSP container moves statements in the _jspservice() method while generating servlets from JSP. For each REQUEST of the client, the service method of the JSP gets invoked hence the code inside the Scriptlet executes for EVERY request. In Scriptlet, a java code is EXECUTED every time the JSP is invoked. Syntax of Scriptlet tag: <% java code %> Here <%%> tags are scriptlet tags and within it, we can place the java code. |
|
| 4. |
What are the various action tags used in JSP? |
|
Answer» Various action tags used in JSP are as follows:
|
|
| 5. |
Explain the anatomy of a JSP page? |
|
Answer» Different JSP elements are used for generating the parts of the page that DIFFER for each request. A JSP page is a regular web page with different JSP elements. The three types of elements with JavaServer Pages are directive, action, and SCRIPTING elements. JSP elements are often used to work with JavaBeans. The elements of the page that are not JSP elements are simply called the “template text”. The template text is commonly HTML, but it could also be any other text. When a page request of JSP is PROCESSED, the template text and the dynamic content GENERATED by the JSP elements are merged, and the RESULT is sent as the response to the browser. |
|
| 6. |
How does JSP processing take place? |
|
Answer» The JSP page is TURNED into a servlet for all the JSP elements to be processed by the server. Then the servlet is executed. The servlet container and the JSP container—are OFTEN combined into one package under the name “web container”. In the translation phase, the JSP container is responsible for converting the JSP page into a servlet and COMPILING the servlet. This is used to automatically initiate the translation phase for a page when the first request for the page is received. In the “request processing” phase, the JSP container is also responsible for INVOKING the JSP page implementation class to process each request and GENERATE the response. |
|
| 7. |
What is an Exception Object? |
||||||||||||
|
Answer» The exception object is an instance of a subclass of THROWABLE (e.g., java.lang. NullPointerException). It is only available on the error pages. The following table lists out the important methods available in the Throwable class:
|
|||||||||||||
| 8. |
Which methods are used for reading form data using JSP? |
|
Answer» JSP is used to handle the FORM data parsing automatically. It DIES so by using the following METHODS depending on the situation:
|
|
| 9. |
What are JSTL Core tags used for? |
|
Answer» The JSTL Core TAGS are used for the FOLLOWING purposes:
Following is the syntax to INCLUDE a tag library: <%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core%> |
|
| 10. |
What is JSTL? |
|
Answer» JSTL stands for Java server pages standard tag library. It is a collection of custom JSP tag libraries that provide common functionality for web development. Following are some of the properties of JSTL:
|
|
| 11. |
What do you mean by JavaBeans? |
|
Answer» JAVABEANS component is a Java class that COMPLIES with CERTAIN coding conventions. JSP elements OFTEN work with JavaBeans. For INFORMATION that describes application entities, JavaBeans are typically used as containers. |
|
| 12. |
What are Implicit JSP Objects? |
||||||||||||||||||||||||||||||
Answer»
|
|||||||||||||||||||||||||||||||