You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Cheung <vi...@justware.co.jp> on 2006/08/15 05:27:15 UTC
Re[2]: How to convert absolute URL to context-relative URL?
Hi,Monkeyden;
Thanks for your reply.
Now I can get the context-relative path, but the extension is also
omitted. How to get the path with extension?
Actually, I want to do this.
URL:
/context-name/appname.do?param1=1¶m2=2
I want to get
/appname.do?param1=1¶m2=2
and use this string to new ActionForward to return in Action.
Thanks.
Regards;
Michael
On Mon, 14 Aug 2006 10:24:19 -0400
Monkeyden <mo...@gmail.com> wrote:
> You may want to look at ActionMapping.getPath().
>
> "Return context-relative path of the submitted request, starting with a
> slash ("/") character, and omitting any filename extension if extension
> mapping is being used."
>
>
> On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
> >
> > Hi, all;
> >
> > I get requestURL from request object in Action, then I want to
> > create a ActionForward object for this URL to return.
> >
> > So I have to convert the absolute URL from requestURL to context
> > relative URL. Thanks a lot.
> >
> > Regards;
> > Michael
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Re[2]: How to convert absolute URL to context-relative URL?
Posted by Puneet Lakhina <pu...@gmail.com>.
On 8/15/06, Michael Cheung <vi...@justware.co.jp> wrote:
>
> Hi,Monkeyden;
>
> Thanks for your reply.
>
> Now I can get the context-relative path, but the extension is also
> omitted. How to get the path with extension?
>
> Actually, I want to do this.
> URL:
> /context-name/appname.do?param1=1¶m2=2
>
> I want to get
> /appname.do?param1=1¶m2=2
> and use this string to new ActionForward to return in Action.
>
request.getServletPath() + "?" + request.getQueryString()
--
Puneet
Re: Re[2]: How to convert absolute URL to context-relative URL?
Posted by Monkeyden <mo...@gmail.com>.
...by the way, they are on the HttpServletRequest object.
On 8/15/06, Monkeyden <mo...@gmail.com> wrote:
>
> Then it will probably look something like the following:
>
> getRequestURI() + "?" + getQueryString()
>
> If not, print out all of the methods below and see what they give you.
> I've always hated the documentation for these methods, not the least of
> which is getRequestURI() which says it includes the protocol but shows
> something different in the example provided. I rarely use them so I need to
> refresh my memory every time I need them.
>
> getRequestURI()
> getRequestURL()
> getServletPath()
> getContextPath()
> getPathInfo()
> getPathTranslated()
> getQueryString()
>
>
> On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
> >
> > Hi,Monkeyden;
> >
> > Thanks for your reply.
> >
> > Now I can get the context-relative path, but the extension is also
> > omitted. How to get the path with extension?
> >
> > Actually, I want to do this.
> > URL:
> > /context-name/appname.do?param1=1¶m2=2
> >
> > I want to get
> > /appname.do?param1=1¶m2=2
> > and use this string to new ActionForward to return in Action.
> >
> > Thanks.
> >
> > Regards;
> > Michael
> >
> >
> > On Mon, 14 Aug 2006 10:24:19 -0400
> > Monkeyden <mo...@gmail.com> wrote:
> >
> > > You may want to look at ActionMapping.getPath ().
> > >
> > > "Return context-relative path of the submitted request, starting with
> > a
> > > slash ("/") character, and omitting any filename extension if
> > extension
> > > mapping is being used."
> > >
> > >
> > > On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
> > > >
> > > > Hi, all;
> > > >
> > > > I get requestURL from request object in Action, then I want to
> > > > create a ActionForward object for this URL to return.
> > > >
> > > > So I have to convert the absolute URL from requestURL to context
> > > > relative URL. Thanks a lot.
> > > >
> > > > Regards;
> > > > Michael
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Re: Re[2]: How to convert absolute URL to context-relative URL?
Posted by Monkeyden <mo...@gmail.com>.
Then it will probably look something like the following:
getRequestURI() + "?" + getQueryString()
If not, print out all of the methods below and see what they give you. I've
always hated the documentation for these methods, not the least of which is
getRequestURI() which says it includes the protocol but shows something
different in the example provided. I rarely use them so I need to refresh
my memory every time I need them.
getRequestURI()
getRequestURL()
getServletPath()
getContextPath()
getPathInfo()
getPathTranslated()
getQueryString()
On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
>
> Hi,Monkeyden;
>
> Thanks for your reply.
>
> Now I can get the context-relative path, but the extension is also
> omitted. How to get the path with extension?
>
> Actually, I want to do this.
> URL:
> /context-name/appname.do?param1=1¶m2=2
>
> I want to get
> /appname.do?param1=1¶m2=2
> and use this string to new ActionForward to return in Action.
>
> Thanks.
>
> Regards;
> Michael
>
>
> On Mon, 14 Aug 2006 10:24:19 -0400
> Monkeyden <mo...@gmail.com> wrote:
>
> > You may want to look at ActionMapping.getPath().
> >
> > "Return context-relative path of the submitted request, starting with a
> > slash ("/") character, and omitting any filename extension if extension
> > mapping is being used."
> >
> >
> > On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
> > >
> > > Hi, all;
> > >
> > > I get requestURL from request object in Action, then I want to
> > > create a ActionForward object for this URL to return.
> > >
> > > So I have to convert the absolute URL from requestURL to context
> > > relative URL. Thanks a lot.
> > >
> > > Regards;
> > > Michael
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Re[2]: How to convert absolute URL to context-relative URL?
Posted by Sr...@3com.com.
Try using this...
ActionForward forward = mapping.findForward("test");
StringBuffer path = new StringBuffer(forward.getPath());
path.append("/appname.do?param1=1¶m2=2");
return new ActionForward(path.toString());
Thanks,
Srinivas.
Michael Cheung
<vividy@justware.
co.jp> To
"Struts Users Mailing List"
08/15/2006 08:57 <us...@struts.apache.org>
AM cc
Subject
Please respond to Re[2]: How to convert absolute URL
"Struts Users to context-relative URL?
Mailing List"
<user@struts.apac
he.org>
Hi,Monkeyden;
Thanks for your reply.
Now I can get the context-relative path, but the extension is also
omitted. How to get the path with extension?
Actually, I want to do this.
URL:
/context-name/appname.do?param1=1¶m2=2
I want to get
/appname.do?param1=1¶m2=2
and use this string to new ActionForward to return in Action.
Thanks.
Regards;
Michael
On Mon, 14 Aug 2006 10:24:19 -0400
Monkeyden <mo...@gmail.com> wrote:
> You may want to look at ActionMapping.getPath().
>
> "Return context-relative path of the submitted request, starting with a
> slash ("/") character, and omitting any filename extension if extension
> mapping is being used."
>
>
> On 8/14/06, Michael Cheung <vi...@justware.co.jp> wrote:
> >
> > Hi, all;
> >
> > I get requestURL from request object in Action, then I want to
> > create a ActionForward object for this URL to return.
> >
> > So I have to convert the absolute URL from requestURL to context
> > relative URL. Thanks a lot.
> >
> > Regards;
> > Michael
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org