Jsp interview questions and answers on advance and basic Jsp with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Jsp also add your Questions if any you have to ask and for apply
in Jsp Tutorials and Training course just send a mail on email@example.com in detail about your self.
Top Jsp interview questions and answers for freshers and experienced
What is Jsp ?
Answer : Based on Java Servlet technology, JSP (JavaServer Pages) allows the platform-independent development of dynamic web applications
Questions : 1 :: Explain JSP and tell its uses?
JSP stands for Java Server Pages. It is a presentation layer technology independent of platform. It comes with SUN’s J2EE platforms. They are like HTML pages but with Java code pieces embedded...View answers
Questions : 2 :: What is the requirement of a tag library?
A collection of custom tags is called a Tag Library. Recurring tasks are handled more easily and reused across multiple applications to increase productivity. They are used by Web Application...View answers
Questions : 3 :: Explain JSP Technology.
JSP is a standard extension of Java and is defined on top of Servlet extensions. Its goal is to simplify management and creation of dynamic web pages. It is platform-independent, secure, and it makes...View answers
Questions : 4 :: Explain Implicit objects in JSP.
Objects created by web container and contain information regarding a particular request, application or page are called Implicit Objects. They are...View answers
Questions : 5 :: How can multiple submits due to refresh button clicks be prevented?
Using a Post/Redirect/Get or a PRG pattern, this problem can be solved.
1. A form filled by the user is submitted to the server using POST or GET method. The state in the database and business model...View answers
Questions : 6 :: Is JSP technology extensible?
Yes, JSP is easily extensible by use and modification of tags, or custom actions, encapsulated in tag libraries.
Questions : 7 :: Differentiate between response.sendRedirect(url) and .
<jsp.forward> element forwards the request object from 1 JSP file to another. Target file can be HTML, servlet or another JSP file, but it should be in the same application context as...View answers
Questions : 8 :: Can a subsequent request be accessed with one's servlet code, if a request attribute is already sent in his JSP?
The request goes out of scope, thus, it cannot be accessed. However, if a request attribute is set in one’s servlet, then it can be accessed in his JSP.
A JSP is a server side component and...View answers
Questions : 9 :: How to include static files in a JSP page?
Static pages are always included using JSP include directive. This way the inclusion is performed in the translation phase once. Note that a relative URL must be supplied for file attribute. Although...View answers
Questions : 10 :: Why is it that JComponent have add() and remove() methods but Component doesn't?
JComponent is a subclass of Container. It contains other Components and JComponents.
Questions : 11 :: How can a thread safe JSP page be implemented?
It can be done by having them implemented by the SingleThreadModel Interface. Add <%@page isThreadSafe=”false” %> directive in the JSP page.
Questions : 12 :: How can the output of JSP or servlet page be prevented from being cached by the browser?
Using appropriate HTTP header attributes to prevent the dynamic content output by a JSP page from being cached by the browser.
Questions : 13 :: How to restrict page errors display in a JSP page?
By setting up an "ErrorPage" attribute of PAGE directory to the name of the error page in the JSP page, and then in the error jsp page set "isErrorpage="TRUE", Errors can be...View answers
Questions : 14 :: What are JSP Actions?
They are XML tags, which direct the server to using existing components or control behavior of JSP Engine. They consist of a typical prefix of “jsp:” and action name.
Questions : 15 :: Differentiate between and .?
Both these tags include information from 1 page to another.
The first tag acts as a function call between two Jsp’s. It is executed each time client page is accessed by the client. It is...View answers
Questions : 16 :: Can constructor be used instead of init(), to initialize servlet?
Yes, it is possible. But it is not preferred because init() was developed because earlier Java versions could not invoke constructors with arguments dynamically. So they could not assign a...View answers
Questions : 17 :: Explain lifecycle methods.
1) jsplnit(): The container calls this to initialize servlet instance. It is called only once for the servlet instance and preceded every other method.
2) _jspService(): The container...View answers
Questions : 18 :: Explain JSP Output comments?
They are comments that can be viewed in HTML Source File.
Questions : 19 :: Define Expression
Expression tag is used to insert Java values directly in the output. Its syntax is <%=expression%>
It contains a scripting language expression that is evaluated, then converted to a string,...View answers
Questions : 20 :: Define Composition.
Composition has a stronger relationship with the object than Aggregation.
Questions : 21 :: Define JSP Scriptlet.
It a JSP tag that encloses Java code in JSP pages. Their syntax is <% %>. Code written in scriptlet executes every time the program is run.
Questions : 22 :: How can information from one JSP be passed to another JSP?
The tag <Jsp:param> allows us to pass information between multiple Jsp’s.
Questions : 23 :: Explain handling of runtime exceptions.
Errorpage attribute is used to uncatch the run-time exceptions forwarded automatically to an error processing page.
It redirects the browser to JSP page error.jsp if any uncaught exception is faces...View answers
Questions : 24 :: Why does _jspService() start with an '_' but other lifecycle methods do not?
Whatever content made in a jsp page goes inside the _jspService() method by the container. If it is override, the compiler gives an error, but the other 2 lifecycles can be easily override. So...View answers
Questions : 25 :: Explain the various scope values for tag.
<jsp:useBean> tag is used to use any java object in the jsp page. Some scope values are :
Questions : 26 :: Show the 2 types of comments in JSP.
The 2 types are: <%–JSP Comment–%><!–HTML comment–>
Questions : 27 :: Can Static method be Override?
We can declare static methods with same signature in subclass, but it is not considered overriding as there won’t be any run-time polymorphism. Hence the answer is ‘No’.
Questions : 28 :: Explain JSP directives.
JSP directives are messages to JSP Engine. They serve as a message from page to container and control the processing of the entire page. They can set global values like class declaration. They do not...View answers
Questions : 29 :: Explain pge Directives.
Page Directives inform the JSP Engine about headers and facilities that the page receives from the environment. It is found at the top of all JSP pages. Its syntax is <%@ page...View answers
Questions : 30 :: Show attributes of page directives.
1)Session : It shows if a session data is available to the page.
2)Import : it shows packages that are imported.
3)isELIgnored : It shows whether EL expressions are ignored when JSP translates into...View answers
Questions : 31 :: What is Include directive?
The include directive statically inserts the contents of a resource into the current JSP. It helps in the reuse of code without duplication. and includes contents of the file at translation time. Its...View answers
Questions : 32 :: Explain the jsp:setProperty action.
It is used to give values to properties of beans that have been referenced beforehand.
<jsp:setProperty name=”ABC” ...View answers
Questions : 33 :: Define Static Block.
It is used to start the static data member. It is executed before classloading.
Questions : 34 :: Explain jsp:plugin action.
This action helps in insertion of a specific object in the browser or embed the element needed to specify the running of applet using Java plugin.
Questions : 35 :: Explain client and server side validation.
Questions : 36 :: What is Translation Phase?
JSP engine translates and compiles a JSP file to a servlet. This servlet moves to the execution phase where requests and responses are handled. They are compiled for the first time they are accessed...View answers
Questions : 37 :: Perform a Browser Redirection from a JSP Page.
Questions : 40 :: How can Automatic creation of session be prevented in a JSP page?
JSP page automatically create sessions for requests. By typing the following, it can be...View answers
Questions : 41 :: How can you avoid scriptlet code in JSP?
JavaBeans or Custom Tags can be used instead of scriptlet code.
Questions : 42 :: Explain the jspDestroy() method.
Whenever a JSP page is about to be destroyed, the container invokes the jspDestroy() method from the javax.servlet.jsp.JspPage interface. Servlets destroy methods are similar to it. It can be easily...View answers
Questions : 43 :: Explain the action.
It is an action used with include or forward standard actions. It helps in passing the parameter names and values to a resource
Questions : 44 :: Explain static method.?
A static method is of the class and not the object of a class. It can be invoked without instance of a class. Static members can also access the static data and change its value.
Questions : 45 :: How to disable scripting?
Scripting can be easily disabled by setting scripting-invalid element of the deployment descriptor to true. It is a sub-element of property group. Its can be false as well.
Questions : 46 :: Define JSP Declaration.?
JSP Declaration are tags used in declaring variables. They are enclosed in <%!%> tag. They are used in declaring functions and...View answers
Questions : 47 :: How can HTML Output be prevented from being cached?
Questions : 48 :: How is JSP better than Servlet technology?
JSP is a technology on the server’s side to make content generation simple. They are document centric, whereas servlets are programs. A Java server page can contain fragments of Java program,...View answers