JSP: Random Information #37

  • Three JSP constructs: scripting elements, actions, directives
  • Scripting elements: expressions, scriptlets, declarations
  • Expression = translates to println in servlets in _jspService methods
     < % = expression %> < % = new java.util.Date() %>

    inserts values directly to the output

  • scriptlet: block of java code : directly inserted into the related servlets in the _jspService method:
    < % java code %>
  • declarations:
    < %! variable and method declarions%>

    Directly placed in the body of the translated servlets

  • >= JSP 1.2 : XML Syntax for expressions, scriptlets, declarations
    Java ExpressionJava CodeJSP Declaration
  • JSP implicit objects: request, response, out, session
  • Implicit objects: application = servletContext = persistent data, config = ServletConfig = initialization parameters, pageContext = context to store reference to objects, and page = this, exception = used by error pages :
  • < %@ directive attribute ="value " %>< %@ directive attribute1 ="value1 " attribute2 ="value2 " ... attributeN ="valueN " %>
  • JSP Directives : page, include, taglib
  • page directive attributes: import, extends, session, isThreadSafe, buffer, autoFlush, contentType, pageEncoding, errorPage, isErrorPage, language, and info
  • < %@ page import="package.class " %>< %@ page import="package.class1,...,package.classN " %>< %@ page extends="somepackage.someclass " %>< %@ page session="true" %>< %@ page session="false" %>< %@ page isThreadSafe="true" %>< %@ page isThreadSafe="false" %> < %@ page buffer="none" %>< %@ page buffer="sizekb" %>< %@ page autoFlush="true" %>< %@ page autoFlush="false" %>< %@ page contentType="MIME-Type " %>< %@ page contentType="MIME-Type ; charset=Character-Set " %>< %@ page contentType="video/mpeg" %>< %@ page pageEncoding="GB_2312-80" %>< %@ page errorPage="Relative URL " %>< %@ page info="Some Message " %>
  • XML Syntax
  • Other directives:
  • < %@ include file="relevantURLspec " %> : output of another file
  • JSP Custom Tag:
     < %@ taglib uri="TagLibraryURI " prefix="someprefix " %>
  • JSP Pages and Java Beans: JSP page can include logics in Java Code – not recommended – rather embed code into beans or custom tags
  • JavaBean: basically a class, visible, also invisible: JSP supports both types:
  • JavaBeans are accessed through Introspections :
  • Introspection: a class that extends BeanInfo Interface
  • JSP action tags for Java Beans: jsp:useBean, jsp:getProperty, jsp:setProperty
  • jsp:useBean: attributes: id, class, scope=(page,request,session,application), beanName, type,
  • jsp:getProperty: name = name of the bean = id of jsp:useBean, property = property to access
  • jsp:setProperty: attributes: name = name of the bean = id of jsp:useBean, property = property to access, value = value to set, use param attribute to extract from request object for setting values
  • To use a bean from JSP page, place the bean class file in one of the accessible servlet directories
  • Custom Tags = alternatives to java beans for JSP = reduces some limitations of JavaBeans (in JSP) like to few methods to access the bean, you may still require to write much java code in JSP [that we want to avoid]

From: http://sitestree.com/?p=4963
Categories:37
Tags:
Post Data:2007-04-22 17:46:00

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>