The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java Jsp Interview Questions

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Java Jsp Interview Questions Posted: May 19, 2015 11:26 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Java Jsp Interview Questions
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement

1.Explain JSP life Cycle methods?

  • jsp engine controls the life cycle of jsp
  • Jsp life cycle is described by three life cycle methods and six life cycle phases

Jsp life cycle methods :

  • jspInit()
  • _jspService()
  • jspDestroy()


  • Jspinit() method is invoked when JSP page is initialized.
  • The _jspService() method corresponds to the body of the jsp page.
  • This method is defined automatically by the JSp container and should never be defined y the JSP page author.

Jsp Life cycle Phases: 

  • Translation phase
  • Compilation phase
  • Instantiation phase
  • initialization phase
  • Servicing phase
  • Destruction phase

Read More at : JSP Life Cycle

2. What are the Jsp Implicit Objects?


  • Implicit objects in jsp are the objects that are created by the container automatically and the container makes all these 9 implicit objects to the developer.
  • We do not need to create them explicitly, since these objects are created and automatically by container and are accessed using standard variables(objects) are called implicit objects.
  • The following are of implicit variables available in the JSP.  

  1. out
  2. request
  3. response
  4. config
  5. application
  6. session
  7. pagecontext
  8. page
  9. exception
Read More at: 9 Jsp Impicit Objects in java

3. Explain Jsp Scripting Elements?

  • Jsp scripting elements are used to embed jva code in to the jsp.
  • Jsp scripting elements are three types
    1. Declaration
    2. Expression
    3. Scriplet
Read More at: Jsp Scripting Elements

4. What are the Directives in Jsp?

  • A jsp directive is a translation time instruction to the jsp engine.
  • we have three kinds of directives.
  1. Page directive
  2. Include directive
  3. Taglib directive

 Read More at: Jsp Directive Elements


 5. What are the differences between include directive and include action?

include directive include action
Processed at translation time Processed at run time
includes the content at translation time includes the content at request time
We can not pass parameters We can pass parameters using
include directive can use relative or absolute path include action uses only relative path
Better to use in static pages Better to use in dynamic pages

6. How to disable session in JSP?

  • By using page directive
  • <%@ page session="false" %> 

7. How can we handle exceptions in a JSP page?

  • We can handle exception in jsp by using error page element of page directive 
  • The errorPage attribute tells the JSP engine which page to display if there is an error while the current page runs.
    The value of the errorPage attribute is a relative URL.
    The following directive displays MyErrorPage.jsp when all uncaught exceptions are thrown

    Syntax:

    errorPage="url"

    Example:

    <%@ page errorPage="error.jsp"%>

8.How can we override -JSPinit() and _jspDestroy() methods in a jsp?

  • Both methods are executed once in a life cycle of a jsp.
  • We can override these two method as shown below.
  • <%!
        public void jspInit() {
            . . .
        }
    %>
  • <%!    
        public void jspDestroy() {
            . . .   
        }
    %>

9.Can a JSP extend a java class?

  • Yes we can extend a java class in jsp
  • <%@ include page extends="classname" %>
  • We can do this because jsp will convert to a servlet so a servlet can extend a class its fine

10.How can we pass information from one jsp to included jsp page?

  • <jsp:include page="employeedetail.jsp" flush="true">
  • <jsp:param name="name" value="abc"/>
  • <jsp:param name="id" value="220"/>

Read: Java Jsp Interview Questions

Topic: Singleton Design Pattern in java Previous Topic   Next Topic Topic: comparable vs comparator in java example

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use