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. |
Explain the JSP while loop. |
|
Answer» The JSP While loop is USED to ITERATE the elements where it has one PARAMETER of the condition. Syntax of While loop: While(i<N){ //Block of statements} |
|
| 2. |
Explain the JSP for loop. |
|
Answer» The JSP For loop is used for ITERATING the elements for a certain CONDITION, and it has the following THREE parameters:
The for loop syntax is as follows: for(inti=0;i<n;i++){ //BLOCK of statements} |
|
| 3. |
What are JSP Operators? |
||||||||||||||||||||||||||||||||||||
|
Answer» JSP Operators support most of the arithmetic and logical operators that are supported by java within expression language (EL) tags. Following are the frequently used jsp operators:
|
|||||||||||||||||||||||||||||||||||||
| 4. |
What is JSP Expression Language (EL)? |
|
Answer» Expression LANGUAGE (EL) was introduced in JSP 2.0. It is a mechanism that simplifies the ACCESSIBILITY of the data stored in JAVABEAN COMPONENTS and other objects like request, session, and application, etc. There are many operators in JSP that are used in EL like arithmetic and logical operators to PERFORM an expression. |
|
| 5. |
What is the difference between JSP and Javascript? |
|
Answer» JSP is a server-side scripting language as it RUNS on the server. Whereas, JAVASCRIPT runs on the client. Commonly, JSP is more used to change the content of a webpage, and JavaScript for the presentation. Both are QUITE commonly used on the same page. |
|
| 6. |
What are the types of elements with Java Server Pages (JSP)? |
||||||||||||||||||||||||||||||||
|
Answer» The three types of elements with Java Server Pages (JSP) are directive, action, and scripting elements.
The Action elements are:
And lastly, the Scripting elements are:
|
|||||||||||||||||||||||||||||||||
| 7. |
Explain the Life Cycle of a servlet. |
|
Answer» A Java class that uses the Servlet Application Programming Interface (API) is a Servlet. The Servlet API consists of many CLASSES and interfaces that define some methods. These methods make it possible to process HTTP requests in a web server-independent manner. A servlet is loaded when a web server receives a request that should be HANDLED by it. Once a servlet has been loaded, the same servlet INSTANCE (object) is called to process succeeding requests. Eventually, the webserver needs to shut down the servlet, typically when the web server itself is shut down. The 3 life cycle methods are:
These methods define the interactions between the web server and the servlet. |
|
| 8. |
What are Servlets? |
|
Answer» JSP PAGES are often combined with SERVLETS in the same application. The JSP specification is based on the Java SERVLET specification. Simply put, a servlet is a piece of code that adds new functionality to a web server, just LIKE CGI and proprietary server extensions such as NSAPI and ISAPI. Compared to other technologies, servlets have a number of advantages:
|
|
| 9. |
What is Java Server Template Engines? |
|
Answer» A Java servlet template engine is a technology for separating presentation from processing. Template engines have been developed as open-source PRODUCTS to help get HTML out of the servlets. These template engines are INTENDED to be used TOGETHER with pure code components (servlets) and use only web pages with SCRIPTING code for the presentation part. Two popular template engines are WebMacro (http://www.webmacro.org) and FreeMarker (http://freemarker.sourceforge.net). |
|
| 10. |
What are some of the advantages of using JSP? |
| Answer» | |
| 11. |
What is the use of JSP? |
|
Answer» Earlier, Common Gateway Interface (CGI) was the only tool for developing dynamic web content and was not very efficient. The web server has to create a new operating system process, load an interpreter and a script, execute the script, and then tear it all down again, for EVERY request that comes in. This is taxing for the server and doesn’t scale well when the number of TRAFFIC increases. Alternatives such as ISAPI from Microsoft, and JAVA Servlets from Sun Microsystems, offer better performance and scalability. However, they generate web PAGES by embedding HTML directly in programming language code. JavaServer Pages (JSP) changes all of that. |
|
| 12. |
How does JSP Initialization take place? |
|
Answer» When a CONTAINER loads a JSP, it invokes the jspInit() METHOD before SERVICING any requests. public VOID jspInit(){ // Initialization code...} |
|
| 13. |
How does JSP work? |
|
Answer» The JSP container has a special servlet called the page compiler. All HTTP requests with URLs that match the .jsp file extension are forwarded to this page compiler by the configuration of the servlet container. The servlet container is turned into a JSP container with this page compiler. When a .jsp page is FIRST called, the page compiler parses and COMPILES the .jsp page into a servlet class. The JSP servlet class is loaded into memory on the successful compilation. For the subsequent calls, the servlet class for that .jsp page is already in memory. Hence, the page compiler servlet will always COMPARE the timestamp of the JSP servlet with the JSP page. If the .jsp page is more CURRENT, recompilation is necessary. With this process, once deployed, JSP PAGES only go through the time-consuming compilation process once. |
|
| 14. |
What is JSP? |
|
Answer» JSP stands for JAVA Server Pages. This technology is used to create dynamic web pages in the form of HyperText Markup Language (HTML). They have embedded Java code PIECES in them. They are an extension to the Servlet Technology and generate Servlet from a PAGE. It is common to use both servlets and JSP pages in the same web APPS. |
|