The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output. You can't use both value and param, but it is permissible to use neither. The param attribute is the name of the request parameter whose value the property is to receive. The the parameter's value is null, or the parameter does not exist, the setProperty action is ignored. The value that is to be assigned to the given property. A value of "*" means that all request parameters whose names match bean property names will be passed to the appropriate setter methods. The Bean must have been previously defined. Here, the jsp:setProperty is executed only if a new object was instantiated, not if an existing one was found.įollowing table lists out the attributes associated with the setProperty action − S.No.ĭesignates the bean the property of which will be set. In this case, the jsp:setProperty is executed regardless of whether a new bean was instantiated or an existing bean was found.Ī second context in which jsp:setProperty can appear is inside the body of a jsp:useBean element, as given below − You can use jsp:setProperty after, but outside of a jsp:useBean element, as given below − There are two basic ways to use the setProperty action − The Bean must have been previously defined before this action. The setProperty action sets the properties of a Bean. Let us now discuss the jsp:setProperty and the jsp:getProperty actions before giving a valid example related to these actions. Gives the name of the bean as specified by the instantiate () method of the class. Specifies the type of the variable that will refer to the object. Once a bean class is loaded, you can use jsp:setProperty and jsp:getProperty actions to modify and retrieve the bean properties.įollowing table lists out the attributes associated with the useBean action − S.No.ĭesignates the full package name of the bean. The simplest way to load a bean is as follows − If an object is not found, it then tries to create the specified object. It first searches for an existing object utilizing the id and scope variables. You will receive the following output − The include action Example Let us now keep all these files in the root directory and try to access main.jsp. Let us define the following two files (a)date.jsp and (b) main.jsp as follows −įollowing is the content of the date.jsp file −įollowing is the content of the main.jsp file − The boolean attribute determines whether the included resource has its buffer flushed before it is included. The relative URL of the page to be included. Unlike the include directive, which inserts the file at the time the JSP page is translated into a servlet, this action inserts the file at the time the page is requested.įollowing table lists out the attributes associated with the include action − S.No. This action lets you insert files into the page being generated. The scope attribute has four possible values: (a) page, (b)request, (c)session, and (d) application. The id attribute and the scope attribute are directly related, as the scope attribute determines the lifespan of the object associated with the id. This attribute identifies the lifecycle of the Action element. If the Action creates an instance of an object, the id value can be used to reference it through the implicit object PageContext. The id attribute uniquely identifies the Action element, and allows the action to be referenced inside the JSP page. There are two attributes that are common to all Action elements: the id attribute and the scope attribute. Used to write template text in JSP pages and documents. Generates browser-specific code that makes an OBJECT or EMBED tag for the Java plugin.ĭefines dynamically-defined XML element's attribute.ĭefines dynamically-defined XML element's body. Inserts the property of a JavaBean into the output. Includes a file at the time the page is requested. The following table lists out the available JSP actions − S.No. There is only one syntax for the Action element, as it conforms to the XML standard −Īction elements are basically predefined functions. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin. These actions use constructs in XML syntax to control the behavior of the servlet engine. In this chapter, we will discuss Actions in JSP.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |