Not sure which part of this misson is bothering you.

Basically, you need:
(1)Get the context path of your web app, by invoking
[ServletContext.getContextPath()]
(2)Build the relative path
(3)Build the query parameters what you want

And then combine all of them.

Most time you can implement this by simple String appending,

If your mission is very complex, you can use library of Apache HttpComponents.
See: http://hc.apache.org/

I think these classes may help:
(1)URIUtils:
http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URIUtils.html
(2)URLEncodedUtils:
http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html
(3)BasicHttpParams:
http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/params/BasicHttpParams.html


If you decide to build the url yourself, you can choose another
library, Apache Commons Codec(which is lighter), to do the
Encode/Decode job for you.
See: 
http://commons.apache.org/codec/api-release/org/apache/commons/codec/net/URLCodec.html




2010/10/28 Altenhof, David Aron <[email protected]>:
> Hi ... I need to create a URL, like one would get from <s:url>, but in an 
> action. Are there any easy ways to do this Struts2, or should I try to fiddle 
> aroung getting a url from ServletContext?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to