URL tag (Miscellaneous Tag)

URL tag (Miscellaneous Tag)

The URL tag has following attributes.

value: It contains the base URL. You can provide the complete URL in this value attributes and can use the URL tag inside the href attribute of the anchor tag.

var: This attributes is used to store the generated URL in the ActionContext which can be later used at any place in the JSP.

action: It is the action name to be targted with the URL to be generate. (Here no need to provide the .action at the end of the provided value)

includeParams: This parameter is used to include the get or post parameters into the generated URL. Possible values are "post or get or none or all"If you provide post then it will take all the request parameter in the generated URL. Default is get. If you provide get then it will take request query parameters into the URL being generated.

includeConetxt:  This attribute is used to prepend the generated URL with the application context. Default is true.

encode: Adds sessionID in the URL if the cookies are not enabled.

Example:
1)
<s:URL value="HelloWorld.action"/>
<a hred='<s:URL value="HelloWorld.action"/>'> Hello World </a>

2)
<s:URL action="HelloWorld" var="myURL">
<s:param name="id" value="199"/>
<s:param name="msg" value="welcome"/>
</s:URL>

<a href="<s:property value="#myURL"/>"> HELLO WORLD </a>

the generated url will be like:

<a href="/contextName/moduleName/HelloWorld.action?id=199&msg=welcome"> HELLO WORLD </a>