Presentation is loading. Please wait.

Presentation is loading. Please wait.

JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,

Similar presentations


Presentation on theme: "JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,"— Presentation transcript:

1 JSP in Action

2 JSP Standard Actions

3 forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params, attribute, body, and fallback

4 Actions: forward, include, and param The forward action lets you about execution of the current page and transfer the request to another page:

5 The include action is similar to forward, the main difference being that it returns control to the including page after the included page has completed execution.

6 Note that Tomcat clears the output buffer upon executing the forward action. Therefore, the HTML code generated up to that point by the current page is lost.

7 The include action does not clear the output buffer. The flush attribute (default false) ensures that the HTML generated so far by the including page is sent to the client before executing the included page. is not the same as

8 Action: useBean jsp:useBean accepts the attributes beanName, class, id, scope, and type, of which only id is mandatory., Tomcat will check whether an object named objName exists in pageContext. If you type with aScope set to one of the words page, request, session, or application, Tomcat will create a variable ojbName of the same type as the object, so that you can access the object in subsequent JSP scripting elements.

9 Also jsp:useBean can create new objects. Whether the useBean does it and what type of variable it makes available for JSP scripting depends on the three remaining attributes: class, type, and beanName. A serialized bean of the xxx.yyyx.Zzz class is expected to be in the WEB-INF\classes\xxx\yyy\Zzz.ser file. If you specify type and set it to a fully qualified class name but specifiy neither class nor beanName, Tomcat won’t instantiate any object and will instead look for it in the given scope.

10 The following code instantiates a MyClass object that remains available as long as the session remains valid: You’ll be able to access it via a scripting variable name myObj in any page within the same session with the following statement.

11 Equivalent to And

12 Actions: setProperty and getProperty A bean property is nothing else than an attribute of a bean’s class, but only when you define for that attribute the standard get and put methods. Both get and put must be there. Otherwise, that class attribute is not a bean property.

13

14 Setting values

15 Sends the value of the property to the output.

16 Action: text You can use the jsp:text action to write template text. Its syntax is straightforward: Template data Its body cannot contain other elements; it can only contain text and EL expressions.

17 Actions: element, attribute and body With the actions element, attribute, and body, you can define XML elements dynamically within a JSP page. XML generated at request time not at compile time.

18

19

20 Action: plugin, params, and fallback How to embed an object in a web page.

21

22 Comments and Escape Characters /*.. */


Download ppt "JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,"

Similar presentations


Ads by Google