Wednesday, 30 January 2013

JSP


 JSP Introduction
 -=-=-=-=-=-=-=-=-=-=-
  Java Server Pages.

  1. Servlets are HTML Embedded Into Java
     where as
     JSP's are Java Embedded Into HTML

  2. Servlets are recompiled and register it in the descriptor
     and loaded for which server has to be restarted
     where as
     JSP's are dynamically compiled and loaded.
     (No Server Restart)
     
 Implicit Objects
 -=-=-=-=-=-=-=-=-=-=-
   out
   response
   request
   session
   config
   application
   exception
 
 JSP Tags
 -=-=-=-=-=-=-=-=-=-=-
  We Hve five Kinds Of JSP Tags

  1. Directive   <%@ directive attributesList %>
  2. Declarative <%! declarations %>
  3. Expression  <%= expression %>
  4. Scriplet    <%  Script or code %>
  5. JSP Actions <jsp:action attributeList />
 
 Directive Tags  <%@ DirectivName attribute="value"....  %>
 -=-=-=-=-=-=-=-=-=-=-
   We have Three Directive Tags

   1. Page Directive
        Used define the page language,import packages,
        define error pages..etc
   2. Include Directive
        Used to incldue an external file into a jsp page.
   3. TagLib Directive
        Used to link and use the cutom tags of jsp.

Page Directive
==================================
        The <%@ page %> directive applies to an entire JSP file

        You can use the <%@ page %> directive more than once in a
        translation unit, but you can only use each attribute, except
        import, once. Because the import attribute is similar to the
        import statement in the Java programming language, you can use a
        <%@ page %> directive with import more than once in a JSP file

        No matter where you position the <%@ page %> directive in a JSP
        file or included files, it applies to the entire translation unit.
        However, it is often good programming style to place it at the top
        of the JSP file.

        Attributs
        ---------------------
        language="java"
                The scripting language used in scriptlets, declarations,
                and expressions in the JSP file and any included files.
                As if now, the only allowed value is java.

        extends="package.class"
                The fully qualified name of the superclass of the Java
                class file this JSP file will be compiled to.

        import="{package.class | package.* }, ..."
                A comma-separated list of Java packages that the JSP file
                should import. The packages (and their classes) are
                available to scriptlets, expressions, and declarations
                within the JSP file. If you want to import more than one
                package, you can specify a comma-separated list after
                import or you can use import more than once in a JSP file.
               
                The following packages are implicitly imported,
                so you don't need to specify them with the import
                attribute:

                        java.lang.*
                        javax.servlet.*
                        javax.servlet.jsp.*
                        javax.servlet.http.*

                You must place the import attribute before the element
                that calls the imported class.

        session="true | false"
                Whether the client must join an HTTP session in order
                to use the JSP page. If the value is true,
                the session object refers to the current or new session.
                If the value is false, you cannot use the session
                object. The default value is true.

        buffer="none | 8kb | sizekb"
                The buffer size in kilobytes used by the out object
                to handle output sent from the compiled JSP page to the
                client Web browser. The default value is 8kb.
                If you specify a buffer size, the output is buffered
                with at least the size you specified.

        autoFlush="true | false"
                Whether the buffered output should be flushed
                automatically when the buffer is full. If set to true
                (the default value), the buffer will be flushed.
                If set to false, an exception will be raised when the
                buffer overflows. You cannot set autoFlush to false when
                buffer is set to none.

        isThreadSafe="true | false"
                Whether thread safety is implemented in the JSP file.
                The default value is true, which means that the JSP
                container can send multiple, concurrent client requests
                to the JSP page. You must write code in the JSP page to
                synchronize the multiple client threads. If you use false,
                the JSP container sends client requests one at a time to
                the JSP page.

        info="text"
                A text string that is incorporated verbatim into the
                compiled JSP page. You can later retrieve the string
                with the Servlet.getServletInfo() method.

        errorPage="relativeURL"
                A pathname to a JSP file that this JSP file sends
                exceptions to. If the pathname begins with a /,
                the path is relative to the JSP application's document
                root directory and is resolved by the Web server.
                If not, the pathname is relative to the current JSP file.

        isErrorPage="true | false"
                Whether the JSP file displays an error page.
                If set to true, you can use the exception object in the
                JSP file. If set to false (the default value),
                you cannot use the exception object in the JSP file.

Include Directive
==================================
        Used to incldue an external file into a jsp page. The file can
        be a jsp file or an image ..etc.

        Attributs
        ---------------------
        file="relativeURL"
                A pathname to a JSP or any other file that this JSP file
                embedded with. If the pathname begins with a /,
                the path is relative to the JSP application's document
                root directory and is resolved by the Web server.
                If not, the pathname is relative to the current JSP file.

Taglib Directive
==================================
        This is used to import custom tag libraries.
   
        Attributs
        ---------------------
        prefix=""
                The prefic to be used with the cutom tags.
        uri="relativeUri"
                This is the uri of the TLD File. TLD-Tag
                Library Descriptor.


1 comments: