File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes s:url Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "s:url" Watch "s:url" New topic
Author

s:url

aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
Hello,

Can any of you please tell me how attributes of <s:url>, the includeParams and encode, will work.

Thanks

Aneesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

From the <s:url...> documentation:

encode: whether to encode parameters.

This determines whether or not the parameters will be URL-encoded.

includeParams: The includeParams attribute may have the value 'none', 'get' or 'all'.

This determines if the current page's parameters will be included in the generated URL. With a value of "get" only the parameters included on the current page's URL will be included. With "all" *all* of the parameters (for instance, from a POST) will be included (IIRC). With "none", none will.
[ December 11, 2008: Message edited by: David Newton ]
aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
Thanks David,

I have given like this.

<s:url id="viewUrl" encode="true" includeParams="none" action="partView" namespace="../public"><s aram name="itemid" value="itemId" /></s:url>

if i am giving like this won't the itemId be passed?

Thanks
Aneesh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yes, it will, if itemId has a value.

For example, if I have an action with a visible "itemId" property the following JSP works as expected:



As an aside, namespace="../public" may generate the correct URL, but seems a bit weird. If the action is defined in a package with the namespace "/public" then the appropriate usage would be namespace="/public".
[ December 11, 2008: Message edited by: David Newton ]
aneesh vijayakumar
Greenhorn

Joined: Jul 01, 2008
Posts: 13
Hi

Thanks David,/public will be alright for me, again thanks.


if I give the <s:url> us mentioned above, the url will look like

http://localhost:8282/Autos/pages/sell/public/partView.action?itemid=30

I have included includeParams="none", then why the itemid is being viewed in the url?

I dont want this itemid to be dispalyed in the url.
Can any one help me to hide or encrypt the itemid=30(other parameters,if any) in the url?

Thanks
Aneesh

[ December 11, 2008: Message edited by: aneesh vijayakumar ]
[ December 11, 2008: Message edited by: aneesh vijayakumar ]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

It's being displayed because you're giving it a parameter.

If you don't want it *displayed* there are a few options including a POST form or JavaScript. If you want it *encrypted* you'll have to do that yourself, or search for a URL encryption library.

You could also check the Struts 2 plugins list to see if a plugin already exists; I don't recall any off the top of my head. It would be easy enough to write, though, and contribute back to the project.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: s:url
 
Similar Threads
regarding struts 2 url tag...!!
Calling Action method using struts-tags
struts2 package tag namespace
how to set javascript varibale in <s:url><s:param> value attribute
Struts2Jquery anchor tag