1. What is JSP?
JavaServer Pages (JSP) technology is the Java platform technology for delivering dynamic content to web applications in a portable, secure and well-defined way. The JSP Technology allows us to use HTML, Java, JavaScript and XML in a single file to create high quality and fully functionaly User Interface components for Web Applications.

2. What do you understand by JSP Actions?
JSP actions are XML tags that direct the server to use existing components or control the behavior of the JSP engine. JSP Actions consist of a typical (XML-based) prefix of “jsp” followed by a colon, followed by the action name followed by one or more attribute parameters.

There are six JSP Actions:

< jsp : include / >
< jsp : forward / >
< jsp : plugin / >
< jsp : usebean / >
< jsp : setProperty / >
< jsp : getProperty / >

3. What is the difference between < jsp : include page = … > and < % @ include file = … >?
Both the tags include information from one JSP page in another. The differences are:

< jsp : include page = … >

This is like a function call from one jsp to another jsp. It is executed ( the included page is executed and the generated html content is included in the content of calling jsp) each time the client page is accessed by the client. This approach is useful while modularizing a web application. If the included file changes then the new content will be included in the output automatically.

< % @ include file = … >

In this case the content of the included file is textually embedded in the page that have < % @ include file=”..”> directive. In this case when the included file changes, the changed content will not get included automatically in the output. This approach is used when the code from one jsp file required to include in multiple jsp files.

4. What is the difference between < jsp : forward page = … > and response.sendRedirect(url)?
The element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file.

sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page. The response.sendRedirect also kills the session variables.

5. Name one advantage of JSP over Servlets? 
Can contain HTML, JavaScript, XML and Java Code whereas Servlets can contain only Java Code, making JSPs more flexible and powerful than Servlets.

However, Servlets have their own place in a J2EE application and cannot be ignored altogether. They have their strengths too which cannot be overseen.

6. What are implicit Objects available to the JSP Page?
Implicit objects are the objects available to the JSP page. These objects are created by Web container and contain information related to a particular request, page, or application. The JSP implicit objects are:

response and

7. What are all the different scope values for the < jsp : useBean > tag?
< jsp : useBean > tag is used to use any java object in the jsp page. Here are the scope values for < jsp : useBean > tag:

a) page
b) request
c) session and
d) application

8. What is JSP Output Comments?
JSP Output Comments are the comments that can be viewed in the HTML source file. They are comments that are enclosed within the < ! – – Your Comments Here – – >

9. What is expression in JSP?
Expression tag is used to insert Java values directly into the output.

Syntax for the Expression tag is: < %= expression % >

An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. The most commonly used language is regular Java.

10. What types of comments are available in the JSP?
There are two types of comments that are allowed in the JSP. They are hidden and output comments.

A hidden comment does not appear in the generated HTML output, while output comments appear in the generated output.

Example of hidden comment:
< % – – This is a hidden comment – – % >

Example of output comment:
< ! – – This is an output comment – – >

11. What is a JSP Scriptlet?
JSP Scriptlets is a term used to refer to pieces of Java code that can be embedded in a JSP PAge. Scriptlets begins with <% tag and ends with %> tag. Java code written inside scriptlet executes every time the JSP is invoked.

12. What are the life-cycle methods of JSP?
Life-cycle methods of the JSP are:

a) jspInit(): The container calls the jspInit() to initialize the servlet instance. It is called before any other method, and is called only once for a servlet instance.

b)_jspService(): The container calls the _jspservice() for each request and it passes the request and the response objects. _jspService() method cann’t be overridden.

c) jspDestroy(): The container calls this when its instance is about to destroyed.
The jspInit() and jspDestroy() methods can be overridden within a JSP page.

13. What are JSP Custom tags?
JSP Custom tags are user defined JSP language elements. JSP custom tags are user defined tags that can encapsulate common functionality. For example you can write your own tag to access the database and performing database operations. You can also write custom tags to encapsulate both simple and complex behaviors in an easy to use syntax. The use of custom tags greatly enhances the functionality and simplifies the readability of JSP pages.

14. What is the role of JSP in MVC Model?
JSP is mostly used to develop the user interface, It plays are role of View in the MVC Model.

15. What do you understand by context initialization parameters?
The context-param element contains the declaration of a web application’s servlet context initialization parameters.

< context – param >
< param – name > name < / param – name > < param – value > value < / param – value >
< / context-param >

The Context Parameters page lets you manage parameters that are accessed through the ServletContext.getInitParameterNames and ServletContext.getInitParameter methods.

16. Can you extend JSP technology?
Yes. JSP technology lets the programmer to extend the jsp to make the programming more easier. JSP can be extended and custom actions & tag libraries can be developed to enhance/extend its features.

17. What do you understand by JSP translation?
JSP translation is an action that refers to the convertion of the JSP Page into a Java Servlet. This class is essentially a servlet class wrapped with features for JSP functionality.

18. How can you prevent the Browser from Caching data of the Pages you visit?
By setting properties that prevent caching in your JSP Page. They are:

<% response.setHeader("pragma","no-cache");//HTTP 1.1 response.setHeader("Cache-Control","no-cache"); response.setHeader("Cache-Control","no-store"); response.addDateHeader("Expires", -1); response.setDateHeader("max-age", 0); //response.setIntHeader ("Expires", -1); //prevents caching at the proxy server response.addHeader("cache-Control", "private"); %>


Please enter your comment!
Please enter your name here