What is JSP?
Java Server Page (JSP) is a technology for creating dynamically generated web pages through the use of servlets.
----------------------------------------------------------------------------------------------------
Syntax of JSP declarative tag ?
<%!
%>
----------------------------------------------------------------------------------------------------
Syntax of JSP expression tag?
<%= Expression Tag %>
----------------------------------------------------------------------------------------------------
What is the difference b/w variable declared inside a declaration and variable declared in scriplet ?
Variable declared inside a declaration tag treated as instance variable and will be placed at class level in the generated servlet.
<%!
int a =10;
%>
Variable declared inside a scriplet tag will be placed inside _jspService() method of generated servlet.
It act as local variable.
<%
int b = 20;
%>
----------------------------------------------------------------------------------------------------
Explain the Life Cycle Method of JSP ?
1. jspInit()
2. _jspService()
3. jspDestroy()
----------------------------------------------------------------------------------------------------
What JSP Life Cycle Method Can I Override ?
We can override jspInit() and jspDestroy() method in our JSP page but we can't override _jspService() method within a JSP Page.
----------------------------------------------------------------------------------------------------
What are the three types of comments in jsp and what's the difference between them?
1- JSP Comment <%-- jsp comment --%>
This is also known as hidden comment.
2- HTML Comment <!-- HTML Comment -->
This is also known as show comment. you can see it in the source code of page.
3- Java Comment
<%
// Single Line Java Comment
/* Multiple line java comment */
%>
----------------------------------------------------------------------------------------------------
What is output or show comment ?
The comment which is visible in the source is called output comment.
HTML comment is knows as output comment.
<!-- The HTML Comment -->
----------------------------------------------------------------------------------------------------
What is Hidden comment ?
JSP comment is known as hidden comment.This comment is only visible in jsp page
<%-- JSP Comment --%>
-----------------------------------------------------------------------------------------------------
What are the JSP implicit objects?
implicit objects are by default available into jsp page.We can use it directly that means no need to explicitly defined.
1. request
2. response
3. session
4. config
5. application
6. exception
7. out
8. page
9. pageContext
-----------------------------------------------------------------------------------------------------
How does jsp handle runtime exception?
You can use errorPage attribute of page directive.
-----------------------------------------------------------------------------------------------------
How can I implement a thread-safe JSP Page? What are the advantage and disadvantage of using it
-----------------------------------------------------------------------------------------------------
What is the difference between ServletContext and PageContext?
ServletContext : ServletContext gives the information about container.
PageContext: PageContext gives the information about request.
-----------------------------------------------------------------------------------------------------
how to stop jsp page to automatically creating a session?
session object is be default available to the JSP .We can make it unavailable by using page directive as follows:
<%@ page session = "false">
-----------------------------------------------------------------------------------------------------
What's a better approach for enabling thread-safe servlet and JSP?
SingleThreadModel Interface or Synchronization?
-----------------------------------------------------------------------------------------------------
What are various attribute of Page Directive ?
Page Directive attribute contains the following 13 attributes.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
-----------------------------------------------------------------------------------------------------
Explain autoflush in jsp ?
-----------------------------------------------------------------------------------------------------
How do you restrict page errors display in the JSP Page ?
You can set errorPage attribute of Page Directive like this.
<%@ errorPage = "myErrorPage.jsp" %>
And myErrorPage.jsp page set isErrorPage = "true"
-----------------------------------------------------------------------------------------------------
What are the different scope available for JSP?
There are four types of scope are available in jsp.
1. page
2. request
3. session
4. application
-----------------------------------------------------------------------------------------------------
How to you use application scope ?
If we want to make our data available to the entire application then we have to use application scope.
----------------------------------------------------------------------------------------------------
What are the different scope values for <jsp:useBean>
There are 4 type of scopes available for <jsp:useBean>
1. page
2. application
3. request
4. session
----------------------------------------------------------------------------------------------------
How to we include static files in jsp page ?
We can include static files in JSP by using include directive
<%@ include file="myfile.jsp" %>
The content of myfile.jsp will be include at translation time .Hence this inclusion is is also knows as static inclusion.
----------------------------------------------------------------------------------------------------
How may ways are possible to perform inclusion ?
http://oraclesoainterview.blogspot.in/2012/06/26_25.html
----------------------------------------------------------------------------------------------------
In which situation we can use static include and dynamic include in JSP?
If target resource won't change frequently , then use static include
<%@ include file="header.jsp" %>
If target resource chaange frequently , then use dynamic include
<% include page ="header.jsp" %>
----------------------------------------------------------------------------------------------------
Syntax of include Directive is : <%@ include file="fileName" %>
Syntax of include Action is : <% jsp: include page ="relativeURL" %>
----------------------------------------------------------------------------------------------------
Difference Between Include Directive and Include Action?
Include Directive Include Action
1. Include directive is processed at the translation time Include Action is processed at RequestTime.
2. Include directive can use relative or absolute path Include Action always use relative path.
3. To include static content recommend Include Directive To include dynamic content recommend Include Action
----------------------------------------------------------------------------------------------------
How can JSP communicate with JSP File?
Import Tag Like this
<%@page import ="mypack.MyJavaFile" %>
----------------------------------------------------------------------------------------------------
How can you pass information from one jsp to included jsp ?
<jsp:param name="a" value="abc" >
----------------------------------------------------------------------------------------------------
What is difference between Web Server and Application Server ?
Web Server does not contain EJB Container so EJB can't be deployed on it.
Application contains EJB container so EJB can be deployed and run on it.
----------------------------------------------------------------------------------------------------
What is difference between URL encoding and URL rewriting ?
URL Encoding :
URL Rewriting:
----------------------------------------------------------------------------------------------------
Difference between ServletContext and ServletConfig ?
----------------------------------------------------------------------------------------------------
Is JSP technology extensible ?
Yes, Custom Action ,tags makes JSP extensible.
----------------------------------------------------------------------------------------------------
How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser.
<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma\","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
----------------------------------------------------------------------------------------------------
How do you pass control from one jsp page to another jsp page ?
To pass control from one jsp page to another or from one servlet to another
1.RequestDispatcher object's forward method.
2.response.sendRedirect() method
----------------------------------------------------------------------------------------------------
Can we implement an interface in a JSP ?
No
Java Server Page (JSP) is a technology for creating dynamically generated web pages through the use of servlets.
----------------------------------------------------------------------------------------------------
Syntax of JSP declarative tag ?
<%!
%>
----------------------------------------------------------------------------------------------------
Syntax of JSP expression tag?
<%= Expression Tag %>
----------------------------------------------------------------------------------------------------
What is the difference b/w variable declared inside a declaration and variable declared in scriplet ?
Variable declared inside a declaration tag treated as instance variable and will be placed at class level in the generated servlet.
<%!
int a =10;
%>
Variable declared inside a scriplet tag will be placed inside _jspService() method of generated servlet.
It act as local variable.
<%
int b = 20;
%>
----------------------------------------------------------------------------------------------------
Explain the Life Cycle Method of JSP ?
1. jspInit()
2. _jspService()
3. jspDestroy()
----------------------------------------------------------------------------------------------------
What JSP Life Cycle Method Can I Override ?
We can override jspInit() and jspDestroy() method in our JSP page but we can't override _jspService() method within a JSP Page.
----------------------------------------------------------------------------------------------------
What are the three types of comments in jsp and what's the difference between them?
1- JSP Comment <%-- jsp comment --%>
This is also known as hidden comment.
2- HTML Comment <!-- HTML Comment -->
This is also known as show comment. you can see it in the source code of page.
3- Java Comment
<%
// Single Line Java Comment
/* Multiple line java comment */
%>
----------------------------------------------------------------------------------------------------
What is output or show comment ?
The comment which is visible in the source is called output comment.
HTML comment is knows as output comment.
<!-- The HTML Comment -->
----------------------------------------------------------------------------------------------------
What is Hidden comment ?
JSP comment is known as hidden comment.This comment is only visible in jsp page
<%-- JSP Comment --%>
-----------------------------------------------------------------------------------------------------
What are the JSP implicit objects?
implicit objects are by default available into jsp page.We can use it directly that means no need to explicitly defined.
1. request
2. response
3. session
4. config
5. application
6. exception
7. out
8. page
9. pageContext
-----------------------------------------------------------------------------------------------------
How does jsp handle runtime exception?
You can use errorPage attribute of page directive.
-----------------------------------------------------------------------------------------------------
How can I implement a thread-safe JSP Page? What are the advantage and disadvantage of using it
-----------------------------------------------------------------------------------------------------
What is the difference between ServletContext and PageContext?
ServletContext : ServletContext gives the information about container.
PageContext: PageContext gives the information about request.
-----------------------------------------------------------------------------------------------------
how to stop jsp page to automatically creating a session?
session object is be default available to the JSP .We can make it unavailable by using page directive as follows:
<%@ page session = "false">
-----------------------------------------------------------------------------------------------------
What's a better approach for enabling thread-safe servlet and JSP?
SingleThreadModel Interface or Synchronization?
-----------------------------------------------------------------------------------------------------
What are various attribute of Page Directive ?
Page Directive attribute contains the following 13 attributes.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
-----------------------------------------------------------------------------------------------------
Explain autoflush in jsp ?
-----------------------------------------------------------------------------------------------------
How do you restrict page errors display in the JSP Page ?
You can set errorPage attribute of Page Directive like this.
<%@ errorPage = "myErrorPage.jsp" %>
And myErrorPage.jsp page set isErrorPage = "true"
-----------------------------------------------------------------------------------------------------
What are the different scope available for JSP?
There are four types of scope are available in jsp.
1. page
2. request
3. session
4. application
-----------------------------------------------------------------------------------------------------
How to you use application scope ?
If we want to make our data available to the entire application then we have to use application scope.
----------------------------------------------------------------------------------------------------
What are the different scope values for <jsp:useBean>
There are 4 type of scopes available for <jsp:useBean>
1. page
2. application
3. request
4. session
----------------------------------------------------------------------------------------------------
How to we include static files in jsp page ?
We can include static files in JSP by using include directive
<%@ include file="myfile.jsp" %>
The content of myfile.jsp will be include at translation time .Hence this inclusion is is also knows as static inclusion.
----------------------------------------------------------------------------------------------------
How may ways are possible to perform inclusion ?
http://oraclesoainterview.blogspot.in/2012/06/26_25.html
----------------------------------------------------------------------------------------------------
In which situation we can use static include and dynamic include in JSP?
If target resource won't change frequently , then use static include
<%@ include file="header.jsp" %>
If target resource chaange frequently , then use dynamic include
<% include page ="header.jsp" %>
----------------------------------------------------------------------------------------------------
Syntax of include Directive is : <%@ include file="fileName" %>
Syntax of include Action is : <% jsp: include page ="relativeURL" %>
----------------------------------------------------------------------------------------------------
Difference Between Include Directive and Include Action?
Include Directive Include Action
1. Include directive is processed at the translation time Include Action is processed at RequestTime.
2. Include directive can use relative or absolute path Include Action always use relative path.
3. To include static content recommend Include Directive To include dynamic content recommend Include Action
----------------------------------------------------------------------------------------------------
How can JSP communicate with JSP File?
Import Tag Like this
<%@page import ="mypack.MyJavaFile" %>
----------------------------------------------------------------------------------------------------
How can you pass information from one jsp to included jsp ?
<jsp:param name="a" value="abc" >
----------------------------------------------------------------------------------------------------
What is difference between Web Server and Application Server ?
Web Server does not contain EJB Container so EJB can't be deployed on it.
Application contains EJB container so EJB can be deployed and run on it.
----------------------------------------------------------------------------------------------------
What is difference between URL encoding and URL rewriting ?
URL Encoding :
URL Rewriting:
----------------------------------------------------------------------------------------------------
Difference between ServletContext and ServletConfig ?
----------------------------------------------------------------------------------------------------
Is JSP technology extensible ?
Yes, Custom Action ,tags makes JSP extensible.
----------------------------------------------------------------------------------------------------
How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser.
<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma\","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
----------------------------------------------------------------------------------------------------
How do you pass control from one jsp page to another jsp page ?
To pass control from one jsp page to another or from one servlet to another
1.RequestDispatcher object's forward method.
2.response.sendRedirect() method
----------------------------------------------------------------------------------------------------
Can we implement an interface in a JSP ?
No
No comments:
Post a Comment