What is JSP?
JSP stands for Java Server Page, It is a server side technology and it is used to prepare presentation/view part in the web application development.
JSP is used to create web application just like Servlet technology. It can be thought of as an extension to Servlet because it provides more functionality than servlet such as expression language, JSTL, etc.
A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than Servlet because we can separate designing and development. It provides some additional features such as Expression Language, Custom Tags, etc.
What are advantages of using JSP?
JSP offer several advantages listed below:
JSP is always compiled before it’s processed by the server unlike.
Performance is significantly better because JSP allows embedding Dynamic Elements in HTML pages itself.
Difference between JSP & Servlets?
In JSP we can easily separate the presentation Logic with Business Logic but in servlets both are combined
One servlet object is communicated with many number of objects, but jsp it is not possible.
What is the web application scope?
There are 3 web application scopes. They are
Request
Session
Application
What is a JSP declaration?
A declaration declares one or more variables or methods that you can use in Java code later in JSP file. You must declare the variable or method before you use it in the JSP file
<%declaration; [declaration;]….%>
What are JSP expressions?
A JSP expression element contains a scripting language expression that is evaluated, converted to a string, and inserted where the expression appears in the JSP file.
What are JSP directives?
A JSP directive affects the overall structure of the servlet class. It usually has the following form: <%@ directive attribute=”value” %>
What are the JSP actions?
JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse Java Beans components, forward the user to another page, or generate HTML for the Java plug-in.
Syntax:
Give some of the JSP action names?
Ans: There are some frequently used jsp actions. They are
jsp:include
jsp:forward
jsp:useBean
jsp:body
jsp:attribute
What is page directive?
The page directive is used to provide instructions to the container that pertain to the current JSP page. You may code page directives anywhere in your JSP page.
What are the various attributes of page directive?
Ans: The following are the page attributes:
• language
• extends
• import
• session
• isThreadSafe
• errorPage
• contentType
• autoFlush
What is include directive?
They include directive is used to includes a file during the translation phase. This directive tells the container to merge the content of other external files with the current JSP during the translation phase.
Syntax: <%@ include file=”relative url”>
What is session Object?
The session object is an instance of javax.servlet.http.HttpSession and is used to track client session between client requests.
Define Filters?
JSP Filters are java classes that can be used in JSP programming for the following purpose:
• To manipulate responses from server before they are sent back to the client
• To intercept requests from a client before they access a resource at back end.
What are cookies?
Cookies are text files stored on the client computer and they are kept for various information tracking purpose.
What is JSTL?
The Java Server Pages Standard Tag Library(JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications. It supports for common,structural tasks such as iteration and conditionals,tags for manipulating XML documents and SQL tags.