You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

JSP support in WebWork is very easy: by default struts-default.xml configures the Dispatcher Result as the default result (see Result Types). This means any JSP 1.2+ container can work with WebWork immediately.

Getting Started

Because JSP support occurs through the Dispatcher Result, which is the default result type, you don't need to specify the type attribute when configuration struts.xml:

<action name="test" class="com.acme.TestAction">
    <result name="success">test-success.jsp</result>
</action>

Then in test-success.jsp:

<%@ taglib prefix="ww" uri="webwork" %>

<html>
<head>
    <title>Hello</title>
</head>
<body>

Hello, <ww:property value="name"/>

</body>
</html>

Where name is a property on your action. That's it!

Servlet / JSP Scoped Objects

The following are ways to obtained Application scope attributes, Session scope attributes, Request scope attributes, Request parameters and framework Context scope parameters:-

Application Scope Attribute

Assuming there's an attribute with name 'myApplicationAttribute' in the Application scope.

<s:property value="%{#application.myApplicationAttribute}" />

Session Scope Attribute

Assuming there's an attribute with name 'mySessionAttribute' in the Session scope.

<s:property value="%{#session.mySessionAttribute}" />

Request Scope Attribute

Assuming there's an attribute with name 'myRequestAttribute' in the Request scope.

<s:property value="%{#request.myRequestAttribute}" />

Request Parameter

Assuming there's a request parameter myParameter (eg. http://host/myApp/myAction.action?myParameter=one).

<s:property value="%{#parameters.myParameter}" />

SAF Context Scope Parameter

Assuming there's a parameter with the name myContextParam in SAF context.

<s:property value="%{#myContextParam}" />

Tag Support

See the JSP Tags documentation for information on how to use the generic Tags provided by the framework.

Exposing the ValueStack

There are a couple of ways to obtain access to ValueStack from JSPs.

Next: JSP Tags

  • No labels