You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jabbar <aj...@gmail.com> on 2008/06/19 18:30:14 UTC
T5: Trying to create a dynamic url to embed in a email
Hello all,
I'm trying to create a url I can embed in an email using the following
List<String> p = new ArrayList<String>();
p.add(emailAddress);
p.add(password);
Link link = resources.createPageLink("Register", false, p.toArray());
//emailVerifier.sendVerification(user,
requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
System.out.println("url is
"+requestGlobals.getHTTPServletRequest().getPathInfo()
+"/"+link.toURI());
the value of the System.out.println is
"url is null/register/username/password"
How do I get the name and port of the web server?
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
or even
requestGlobals.getHTTPServletRequest().getRequestURL()..append(link.toURI());
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> sorry, i went wrong
> use :
>
> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
> link.toURI();
>
>
> 2008/6/19 Jabbar <aj...@gmail.com>:
>
>> Hello Sven,
>>
>> I got
>>
>> "url is /register/username/password"
>>
>>
>>
>>
>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>> > try
>> >
>> > Link link = resources.createPageLink("Register", false, p.toArray());
>> > System.err.println(link.toAbsoluteURI())
>> >
>> > 2008/6/19 Jabbar <aj...@gmail.com>:
>> >
>> >> Hello all,
>> >>
>> >> I'm trying to create a url I can embed in an email using the following
>> >>
>> >> List<String> p = new ArrayList<String>();
>> >> p.add(emailAddress);
>> >> p.add(password);
>> >> Link link = resources.createPageLink("Register", false,
>> >> p.toArray());
>> >> //emailVerifier.sendVerification(user,
>> >> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>> >> System.out.println("url is
>> >> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>> >> +"/"+link.toURI());
>> >>
>> >> the value of the System.out.println is
>> >> "url is null/register/username/password"
>> >>
>> >> How do I get the name and port of the web server?
>> >>
>> >> --
>> >> Thanks
>> >>
>> >> A Jabbar Azam
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > with regards
>> > Sven Homburg
>> > http://tapestry5-components.googlecode.com
>> > http://chenillekit.googlecode.com
>> >
>>
>>
>>
>> --
>> Thanks
>>
>> A Jabbar Azam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Jabbar <aj...@gmail.com>.
Fernando,
That does return what I want.
Thanks
2008/6/19 Fernando Padilla <fe...@alum.mit.edu>:
> We use something like this to construct the baseUrl from a request. So it
> will either be to the root of the server, or to the root of the context
> path. So I usually do:
>
> getAbsoluteRootPath( request ) + link.toAbsoluteURI();
>
>
>
>
>
> public static String getAbsoluteContextPath( HttpServletRequest
> request ) {
> return getAbsoluteRootPath( request ) +
> request.getContextPath();
> }
>
> public static String getAbsoluteRootPath( HttpServletRequest request
> ) {
> StringBuilder sb = new StringBuilder();
> String scheme = request.getScheme();
> int port = request.getServerPort();
> sb.append( scheme );
> sb.append( "://" );
> sb.append( request.getServerName() );
> if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || (
> scheme.equals( "https" ) && port == 443 ) ) ) {
> sb.append( ":" + port );
> }
> return sb.toString();
> }
>
>
>
> Jabbar wrote:
>>
>> Sven,
>>
>> I got the following
>>
>> url is http://localhost:8080/emaildetails.formregister/username/password
>>
>> Its actually showing the request url as well as the page and context
>> parameters we have specified using createPageLink. It think with a bit
>> of string manipulation I can get the result I want. There ought to be
>> a more elegant way to do this though...
>>
>> Thanks for your help
>>
>>
>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>
>>> sorry, i went wrong
>>> use :
>>>
>>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>>> link.toURI();
>>>
>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>
>>>> Hello Sven,
>>>>
>>>> I got
>>>>
>>>> "url is /register/username/password"
>>>>
>>>>
>>>>
>>>>
>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>>
>>>>> try
>>>>>
>>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>>> System.err.println(link.toAbsoluteURI())
>>>>>
>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I'm trying to create a url I can embed in an email using the following
>>>>>>
>>>>>> List<String> p = new ArrayList<String>();
>>>>>> p.add(emailAddress);
>>>>>> p.add(password);
>>>>>> Link link = resources.createPageLink("Register", false,
>>>>>> p.toArray());
>>>>>> //emailVerifier.sendVerification(user,
>>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>>> System.out.println("url is
>>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>>> +"/"+link.toURI());
>>>>>>
>>>>>> the value of the System.out.println is
>>>>>> "url is null/register/username/password"
>>>>>>
>>>>>> How do I get the name and port of the web server?
>>>>>>
>>>>>> --
>>>>>> Thanks
>>>>>>
>>>>>> A Jabbar Azam
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> with regards
>>>>> Sven Homburg
>>>>> http://tapestry5-components.googlecode.com
>>>>> http://chenillekit.googlecode.com
>>>>>
>>>>
>>>>
>>>> --
>>>> Thanks
>>>>
>>>> A Jabbar Azam
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>> --
>>> with regards
>>> Sven Homburg
>>> http://tapestry5-components.googlecode.com
>>> http://chenillekit.googlecode.com
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Jabbar <aj...@gmail.com>.
Sven,
I'm using your solution. It's smaller and more elegant.
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> i fiddle around with regexpr to avoid the getAbsoluteRootPath(
> HttpServletRequest request) construct
> here is the result:
>
> public String getURL()
> {
> Link link = linkFactory.createPageLink("Start", false, "username",
> "password");
> String requestURL =
> globals.getHTTPServletRequest().getRequestURL().toString();
> return requestURL.replaceAll("[^\\/]+$", "") + link.toURI();
> }
>
> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>
>> fernando,
>>
>> sorry, i dont thought that the url from getRequestURL may be not the base
>> url
>>
>>
>>
>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>
>>> Fernando,
>>>
>>> do you think you are coding better then the guys from Sun ?
>>> why dont you use the HTTPServletRequest method "getRequestURL()" ?
>>>
>>> Jabbar,
>>> if you build the link via the LinkFactory instead the ComponentResource
>>> the result is that what you want:
>>>
>>> /**
>>> * t5components start page
>>> */
>>> public class Start
>>> {
>>> @Inject
>>> private RequestGlobals globals;
>>>
>>> @Inject
>>> private LinkFactory linkFactory;
>>>
>>> public String getURL1()
>>> {
>>> Link link = linkFactory.createPageLink("Start", false, "username",
>>> "password");
>>> return
>>> globals.getHTTPServletRequest().getRequestURL().append(link.toURI()).toString();
>>> }
>>> }
>>>
>>>
>>>
>>> 2008/6/19 Fernando Padilla <fe...@alum.mit.edu>:
>>>
>>>> We use something like this to construct the baseUrl from a request. So
>>>> it will either be to the root of the server, or to the root of the context
>>>> path. So I usually do:
>>>>
>>>>
>>>> getAbsoluteRootPath( request ) + link.toAbsoluteURI();
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> public static String getAbsoluteContextPath( HttpServletRequest
>>>> request ) {
>>>> return getAbsoluteRootPath( request ) +
>>>> request.getContextPath();
>>>> }
>>>>
>>>> public static String getAbsoluteRootPath( HttpServletRequest
>>>> request ) {
>>>> StringBuilder sb = new StringBuilder();
>>>> String scheme = request.getScheme();
>>>> int port = request.getServerPort();
>>>> sb.append( scheme );
>>>> sb.append( "://" );
>>>> sb.append( request.getServerName() );
>>>> if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || (
>>>> scheme.equals( "https" ) && port == 443 ) ) ) {
>>>> sb.append( ":" + port );
>>>> }
>>>> return sb.toString();
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> Jabbar wrote:
>>>>
>>>>> Sven,
>>>>>
>>>>> I got the following
>>>>>
>>>>> url is
>>>>> http://localhost:8080/emaildetails.formregister/username/password
>>>>>
>>>>> Its actually showing the request url as well as the page and context
>>>>> parameters we have specified using createPageLink. It think with a bit
>>>>> of string manipulation I can get the result I want. There ought to be
>>>>> a more elegant way to do this though...
>>>>>
>>>>> Thanks for your help
>>>>>
>>>>>
>>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>>
>>>>>> sorry, i went wrong
>>>>>> use :
>>>>>>
>>>>>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>>>>>> link.toURI();
>>>>>>
>>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>>
>>>>>> Hello Sven,
>>>>>>>
>>>>>>> I got
>>>>>>>
>>>>>>> "url is /register/username/password"
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>>>>
>>>>>>>> try
>>>>>>>>
>>>>>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>>>>>> System.err.println(link.toAbsoluteURI())
>>>>>>>>
>>>>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>>
>>>>>>>>> I'm trying to create a url I can embed in an email using the
>>>>>>>>> following
>>>>>>>>>
>>>>>>>>> List<String> p = new ArrayList<String>();
>>>>>>>>> p.add(emailAddress);
>>>>>>>>> p.add(password);
>>>>>>>>> Link link = resources.createPageLink("Register",
>>>>>>>>> false,
>>>>>>>>> p.toArray());
>>>>>>>>> //emailVerifier.sendVerification(user,
>>>>>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>>>>>> System.out.println("url is
>>>>>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>>>>>> +"/"+link.toURI());
>>>>>>>>>
>>>>>>>>> the value of the System.out.println is
>>>>>>>>> "url is null/register/username/password"
>>>>>>>>>
>>>>>>>>> How do I get the name and port of the web server?
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> A Jabbar Azam
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> with regards
>>>>>>>> Sven Homburg
>>>>>>>> http://tapestry5-components.googlecode.com
>>>>>>>> http://chenillekit.googlecode.com
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Thanks
>>>>>>>
>>>>>>> A Jabbar Azam
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> with regards
>>>>>> Sven Homburg
>>>>>> http://tapestry5-components.googlecode.com
>>>>>> http://chenillekit.googlecode.com
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>>
>>> --
>>> with regards
>>> Sven Homburg
>>> http://tapestry5-components.googlecode.com
>>> http://chenillekit.googlecode.com
>>>
>>
>>
>>
>> --
>> with regards
>> Sven Homburg
>> http://tapestry5-components.googlecode.com
>> http://chenillekit.googlecode.com
>>
>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
i fiddle around with regexpr to avoid the getAbsoluteRootPath(
HttpServletRequest request) construct
here is the result:
public String getURL()
{
Link link = linkFactory.createPageLink("Start", false, "username",
"password");
String requestURL =
globals.getHTTPServletRequest().getRequestURL().toString();
return requestURL.replaceAll("[^\\/]+$", "") + link.toURI();
}
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> fernando,
>
> sorry, i dont thought that the url from getRequestURL may be not the base
> url
>
>
>
> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>
>> Fernando,
>>
>> do you think you are coding better then the guys from Sun ?
>> why dont you use the HTTPServletRequest method "getRequestURL()" ?
>>
>> Jabbar,
>> if you build the link via the LinkFactory instead the ComponentResource
>> the result is that what you want:
>>
>> /**
>> * t5components start page
>> */
>> public class Start
>> {
>> @Inject
>> private RequestGlobals globals;
>>
>> @Inject
>> private LinkFactory linkFactory;
>>
>> public String getURL1()
>> {
>> Link link = linkFactory.createPageLink("Start", false, "username",
>> "password");
>> return
>> globals.getHTTPServletRequest().getRequestURL().append(link.toURI()).toString();
>> }
>> }
>>
>>
>>
>> 2008/6/19 Fernando Padilla <fe...@alum.mit.edu>:
>>
>>> We use something like this to construct the baseUrl from a request. So
>>> it will either be to the root of the server, or to the root of the context
>>> path. So I usually do:
>>>
>>>
>>> getAbsoluteRootPath( request ) + link.toAbsoluteURI();
>>>
>>>
>>>
>>>
>>>
>>> public static String getAbsoluteContextPath( HttpServletRequest
>>> request ) {
>>> return getAbsoluteRootPath( request ) +
>>> request.getContextPath();
>>> }
>>>
>>> public static String getAbsoluteRootPath( HttpServletRequest
>>> request ) {
>>> StringBuilder sb = new StringBuilder();
>>> String scheme = request.getScheme();
>>> int port = request.getServerPort();
>>> sb.append( scheme );
>>> sb.append( "://" );
>>> sb.append( request.getServerName() );
>>> if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || (
>>> scheme.equals( "https" ) && port == 443 ) ) ) {
>>> sb.append( ":" + port );
>>> }
>>> return sb.toString();
>>>
>>> }
>>>
>>>
>>>
>>> Jabbar wrote:
>>>
>>>> Sven,
>>>>
>>>> I got the following
>>>>
>>>> url is
>>>> http://localhost:8080/emaildetails.formregister/username/password
>>>>
>>>> Its actually showing the request url as well as the page and context
>>>> parameters we have specified using createPageLink. It think with a bit
>>>> of string manipulation I can get the result I want. There ought to be
>>>> a more elegant way to do this though...
>>>>
>>>> Thanks for your help
>>>>
>>>>
>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>
>>>>> sorry, i went wrong
>>>>> use :
>>>>>
>>>>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>>>>> link.toURI();
>>>>>
>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>
>>>>> Hello Sven,
>>>>>>
>>>>>> I got
>>>>>>
>>>>>> "url is /register/username/password"
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>>>
>>>>>>> try
>>>>>>>
>>>>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>>>>> System.err.println(link.toAbsoluteURI())
>>>>>>>
>>>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>>>
>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> I'm trying to create a url I can embed in an email using the
>>>>>>>> following
>>>>>>>>
>>>>>>>> List<String> p = new ArrayList<String>();
>>>>>>>> p.add(emailAddress);
>>>>>>>> p.add(password);
>>>>>>>> Link link = resources.createPageLink("Register",
>>>>>>>> false,
>>>>>>>> p.toArray());
>>>>>>>> //emailVerifier.sendVerification(user,
>>>>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>>>>> System.out.println("url is
>>>>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>>>>> +"/"+link.toURI());
>>>>>>>>
>>>>>>>> the value of the System.out.println is
>>>>>>>> "url is null/register/username/password"
>>>>>>>>
>>>>>>>> How do I get the name and port of the web server?
>>>>>>>>
>>>>>>>> --
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> A Jabbar Azam
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> --
>>>>>>> with regards
>>>>>>> Sven Homburg
>>>>>>> http://tapestry5-components.googlecode.com
>>>>>>> http://chenillekit.googlecode.com
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Thanks
>>>>>>
>>>>>> A Jabbar Azam
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> with regards
>>>>> Sven Homburg
>>>>> http://tapestry5-components.googlecode.com
>>>>> http://chenillekit.googlecode.com
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>> --
>> with regards
>> Sven Homburg
>> http://tapestry5-components.googlecode.com
>> http://chenillekit.googlecode.com
>>
>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
fernando,
sorry, i dont thought that the url from getRequestURL may be not the base
url
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> Fernando,
>
> do you think you are coding better then the guys from Sun ?
> why dont you use the HTTPServletRequest method "getRequestURL()" ?
>
> Jabbar,
> if you build the link via the LinkFactory instead the ComponentResource
> the result is that what you want:
>
> /**
> * t5components start page
> */
> public class Start
> {
> @Inject
> private RequestGlobals globals;
>
> @Inject
> private LinkFactory linkFactory;
>
> public String getURL1()
> {
> Link link = linkFactory.createPageLink("Start", false, "username",
> "password");
> return
> globals.getHTTPServletRequest().getRequestURL().append(link.toURI()).toString();
> }
> }
>
>
>
> 2008/6/19 Fernando Padilla <fe...@alum.mit.edu>:
>
>> We use something like this to construct the baseUrl from a request. So it
>> will either be to the root of the server, or to the root of the context
>> path. So I usually do:
>>
>>
>> getAbsoluteRootPath( request ) + link.toAbsoluteURI();
>>
>>
>>
>>
>>
>> public static String getAbsoluteContextPath( HttpServletRequest
>> request ) {
>> return getAbsoluteRootPath( request ) +
>> request.getContextPath();
>> }
>>
>> public static String getAbsoluteRootPath( HttpServletRequest
>> request ) {
>> StringBuilder sb = new StringBuilder();
>> String scheme = request.getScheme();
>> int port = request.getServerPort();
>> sb.append( scheme );
>> sb.append( "://" );
>> sb.append( request.getServerName() );
>> if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || (
>> scheme.equals( "https" ) && port == 443 ) ) ) {
>> sb.append( ":" + port );
>> }
>> return sb.toString();
>>
>> }
>>
>>
>>
>> Jabbar wrote:
>>
>>> Sven,
>>>
>>> I got the following
>>>
>>> url is http://localhost:8080/emaildetails.formregister/username/password
>>>
>>> Its actually showing the request url as well as the page and context
>>> parameters we have specified using createPageLink. It think with a bit
>>> of string manipulation I can get the result I want. There ought to be
>>> a more elegant way to do this though...
>>>
>>> Thanks for your help
>>>
>>>
>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>
>>>> sorry, i went wrong
>>>> use :
>>>>
>>>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>>>> link.toURI();
>>>>
>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>
>>>> Hello Sven,
>>>>>
>>>>> I got
>>>>>
>>>>> "url is /register/username/password"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>>
>>>>>> try
>>>>>>
>>>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>>>> System.err.println(link.toAbsoluteURI())
>>>>>>
>>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>>
>>>>>> Hello all,
>>>>>>>
>>>>>>> I'm trying to create a url I can embed in an email using the
>>>>>>> following
>>>>>>>
>>>>>>> List<String> p = new ArrayList<String>();
>>>>>>> p.add(emailAddress);
>>>>>>> p.add(password);
>>>>>>> Link link = resources.createPageLink("Register", false,
>>>>>>> p.toArray());
>>>>>>> //emailVerifier.sendVerification(user,
>>>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>>>> System.out.println("url is
>>>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>>>> +"/"+link.toURI());
>>>>>>>
>>>>>>> the value of the System.out.println is
>>>>>>> "url is null/register/username/password"
>>>>>>>
>>>>>>> How do I get the name and port of the web server?
>>>>>>>
>>>>>>> --
>>>>>>> Thanks
>>>>>>>
>>>>>>> A Jabbar Azam
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> with regards
>>>>>> Sven Homburg
>>>>>> http://tapestry5-components.googlecode.com
>>>>>> http://chenillekit.googlecode.com
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Thanks
>>>>>
>>>>> A Jabbar Azam
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>> --
>>>> with regards
>>>> Sven Homburg
>>>> http://tapestry5-components.googlecode.com
>>>> http://chenillekit.googlecode.com
>>>>
>>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
Fernando,
do you think you are coding better then the guys from Sun ?
why dont you use the HTTPServletRequest method "getRequestURL()" ?
Jabbar,
if you build the link via the LinkFactory instead the ComponentResource
the result is that what you want:
/**
* t5components start page
*/
public class Start
{
@Inject
private RequestGlobals globals;
@Inject
private LinkFactory linkFactory;
public String getURL1()
{
Link link = linkFactory.createPageLink("Start", false, "username",
"password");
return
globals.getHTTPServletRequest().getRequestURL().append(link.toURI()).toString();
}
}
2008/6/19 Fernando Padilla <fe...@alum.mit.edu>:
> We use something like this to construct the baseUrl from a request. So it
> will either be to the root of the server, or to the root of the context
> path. So I usually do:
>
> getAbsoluteRootPath( request ) + link.toAbsoluteURI();
>
>
>
>
>
> public static String getAbsoluteContextPath( HttpServletRequest
> request ) {
> return getAbsoluteRootPath( request ) +
> request.getContextPath();
> }
>
> public static String getAbsoluteRootPath( HttpServletRequest request
> ) {
> StringBuilder sb = new StringBuilder();
> String scheme = request.getScheme();
> int port = request.getServerPort();
> sb.append( scheme );
> sb.append( "://" );
> sb.append( request.getServerName() );
> if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || (
> scheme.equals( "https" ) && port == 443 ) ) ) {
> sb.append( ":" + port );
> }
> return sb.toString();
>
> }
>
>
>
> Jabbar wrote:
>
>> Sven,
>>
>> I got the following
>>
>> url is http://localhost:8080/emaildetails.formregister/username/password
>>
>> Its actually showing the request url as well as the page and context
>> parameters we have specified using createPageLink. It think with a bit
>> of string manipulation I can get the result I want. There ought to be
>> a more elegant way to do this though...
>>
>> Thanks for your help
>>
>>
>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>
>>> sorry, i went wrong
>>> use :
>>>
>>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>>> link.toURI();
>>>
>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>
>>> Hello Sven,
>>>>
>>>> I got
>>>>
>>>> "url is /register/username/password"
>>>>
>>>>
>>>>
>>>>
>>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>>
>>>>> try
>>>>>
>>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>>> System.err.println(link.toAbsoluteURI())
>>>>>
>>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>>
>>>>> Hello all,
>>>>>>
>>>>>> I'm trying to create a url I can embed in an email using the following
>>>>>>
>>>>>> List<String> p = new ArrayList<String>();
>>>>>> p.add(emailAddress);
>>>>>> p.add(password);
>>>>>> Link link = resources.createPageLink("Register", false,
>>>>>> p.toArray());
>>>>>> //emailVerifier.sendVerification(user,
>>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>>> System.out.println("url is
>>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>>> +"/"+link.toURI());
>>>>>>
>>>>>> the value of the System.out.println is
>>>>>> "url is null/register/username/password"
>>>>>>
>>>>>> How do I get the name and port of the web server?
>>>>>>
>>>>>> --
>>>>>> Thanks
>>>>>>
>>>>>> A Jabbar Azam
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> with regards
>>>>> Sven Homburg
>>>>> http://tapestry5-components.googlecode.com
>>>>> http://chenillekit.googlecode.com
>>>>>
>>>>>
>>>>
>>>> --
>>>> Thanks
>>>>
>>>> A Jabbar Azam
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>> --
>>> with regards
>>> Sven Homburg
>>> http://tapestry5-components.googlecode.com
>>> http://chenillekit.googlecode.com
>>>
>>>
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Fernando Padilla <fe...@alum.mit.edu>.
We use something like this to construct the baseUrl from a request. So
it will either be to the root of the server, or to the root of the
context path. So I usually do:
getAbsoluteRootPath( request ) + link.toAbsoluteURI();
public static String getAbsoluteContextPath( HttpServletRequest request ) {
return getAbsoluteRootPath( request ) + request.getContextPath();
}
public static String getAbsoluteRootPath( HttpServletRequest request ) {
StringBuilder sb = new StringBuilder();
String scheme = request.getScheme();
int port = request.getServerPort();
sb.append( scheme );
sb.append( "://" );
sb.append( request.getServerName() );
if ( ! ( ( scheme.equals( "http" ) && port == 80 ) || ( scheme.equals(
"https" ) && port == 443 ) ) ) {
sb.append( ":" + port );
}
return sb.toString();
}
Jabbar wrote:
> Sven,
>
> I got the following
>
> url is http://localhost:8080/emaildetails.formregister/username/password
>
> Its actually showing the request url as well as the page and context
> parameters we have specified using createPageLink. It think with a bit
> of string manipulation I can get the result I want. There ought to be
> a more elegant way to do this though...
>
> Thanks for your help
>
>
> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>> sorry, i went wrong
>> use :
>>
>> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
>> link.toURI();
>>
>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>
>>> Hello Sven,
>>>
>>> I got
>>>
>>> "url is /register/username/password"
>>>
>>>
>>>
>>>
>>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>>>> try
>>>>
>>>> Link link = resources.createPageLink("Register", false, p.toArray());
>>>> System.err.println(link.toAbsoluteURI())
>>>>
>>>> 2008/6/19 Jabbar <aj...@gmail.com>:
>>>>
>>>>> Hello all,
>>>>>
>>>>> I'm trying to create a url I can embed in an email using the following
>>>>>
>>>>> List<String> p = new ArrayList<String>();
>>>>> p.add(emailAddress);
>>>>> p.add(password);
>>>>> Link link = resources.createPageLink("Register", false,
>>>>> p.toArray());
>>>>> //emailVerifier.sendVerification(user,
>>>>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>>>>> System.out.println("url is
>>>>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>>>>> +"/"+link.toURI());
>>>>>
>>>>> the value of the System.out.println is
>>>>> "url is null/register/username/password"
>>>>>
>>>>> How do I get the name and port of the web server?
>>>>>
>>>>> --
>>>>> Thanks
>>>>>
>>>>> A Jabbar Azam
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>
>>>> --
>>>> with regards
>>>> Sven Homburg
>>>> http://tapestry5-components.googlecode.com
>>>> http://chenillekit.googlecode.com
>>>>
>>>
>>>
>>> --
>>> Thanks
>>>
>>> A Jabbar Azam
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> --
>> with regards
>> Sven Homburg
>> http://tapestry5-components.googlecode.com
>> http://chenillekit.googlecode.com
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Jabbar <aj...@gmail.com>.
Sven,
I got the following
url is http://localhost:8080/emaildetails.formregister/username/password
Its actually showing the request url as well as the page and context
parameters we have specified using createPageLink. It think with a bit
of string manipulation I can get the result I want. There ought to be
a more elegant way to do this though...
Thanks for your help
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> sorry, i went wrong
> use :
>
> requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
> link.toURI();
>
> 2008/6/19 Jabbar <aj...@gmail.com>:
>
>> Hello Sven,
>>
>> I got
>>
>> "url is /register/username/password"
>>
>>
>>
>>
>> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
>> > try
>> >
>> > Link link = resources.createPageLink("Register", false, p.toArray());
>> > System.err.println(link.toAbsoluteURI())
>> >
>> > 2008/6/19 Jabbar <aj...@gmail.com>:
>> >
>> >> Hello all,
>> >>
>> >> I'm trying to create a url I can embed in an email using the following
>> >>
>> >> List<String> p = new ArrayList<String>();
>> >> p.add(emailAddress);
>> >> p.add(password);
>> >> Link link = resources.createPageLink("Register", false,
>> >> p.toArray());
>> >> //emailVerifier.sendVerification(user,
>> >> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>> >> System.out.println("url is
>> >> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>> >> +"/"+link.toURI());
>> >>
>> >> the value of the System.out.println is
>> >> "url is null/register/username/password"
>> >>
>> >> How do I get the name and port of the web server?
>> >>
>> >> --
>> >> Thanks
>> >>
>> >> A Jabbar Azam
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > with regards
>> > Sven Homburg
>> > http://tapestry5-components.googlecode.com
>> > http://chenillekit.googlecode.com
>> >
>>
>>
>>
>> --
>> Thanks
>>
>> A Jabbar Azam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
sorry, i went wrong
use :
requestGlobals.getHTTPServletRequest().getRequestURL().toString() +
link.toURI();
2008/6/19 Jabbar <aj...@gmail.com>:
> Hello Sven,
>
> I got
>
> "url is /register/username/password"
>
>
>
>
> 2008/6/19 Sven Homburg <ho...@googlemail.com>:
> > try
> >
> > Link link = resources.createPageLink("Register", false, p.toArray());
> > System.err.println(link.toAbsoluteURI())
> >
> > 2008/6/19 Jabbar <aj...@gmail.com>:
> >
> >> Hello all,
> >>
> >> I'm trying to create a url I can embed in an email using the following
> >>
> >> List<String> p = new ArrayList<String>();
> >> p.add(emailAddress);
> >> p.add(password);
> >> Link link = resources.createPageLink("Register", false,
> >> p.toArray());
> >> //emailVerifier.sendVerification(user,
> >> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
> >> System.out.println("url is
> >> "+requestGlobals.getHTTPServletRequest().getPathInfo()
> >> +"/"+link.toURI());
> >>
> >> the value of the System.out.println is
> >> "url is null/register/username/password"
> >>
> >> How do I get the name and port of the web server?
> >>
> >> --
> >> Thanks
> >>
> >> A Jabbar Azam
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > with regards
> > Sven Homburg
> > http://tapestry5-components.googlecode.com
> > http://chenillekit.googlecode.com
> >
>
>
>
> --
> Thanks
>
> A Jabbar Azam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Jabbar <aj...@gmail.com>.
Hello Sven,
I got
"url is /register/username/password"
2008/6/19 Sven Homburg <ho...@googlemail.com>:
> try
>
> Link link = resources.createPageLink("Register", false, p.toArray());
> System.err.println(link.toAbsoluteURI())
>
> 2008/6/19 Jabbar <aj...@gmail.com>:
>
>> Hello all,
>>
>> I'm trying to create a url I can embed in an email using the following
>>
>> List<String> p = new ArrayList<String>();
>> p.add(emailAddress);
>> p.add(password);
>> Link link = resources.createPageLink("Register", false,
>> p.toArray());
>> //emailVerifier.sendVerification(user,
>> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
>> System.out.println("url is
>> "+requestGlobals.getHTTPServletRequest().getPathInfo()
>> +"/"+link.toURI());
>>
>> the value of the System.out.println is
>> "url is null/register/username/password"
>>
>> How do I get the name and port of the web server?
>>
>> --
>> Thanks
>>
>> A Jabbar Azam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> http://chenillekit.googlecode.com
>
--
Thanks
A Jabbar Azam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Trying to create a dynamic url to embed in a email
Posted by Sven Homburg <ho...@googlemail.com>.
try
Link link = resources.createPageLink("Register", false, p.toArray());
System.err.println(link.toAbsoluteURI())
2008/6/19 Jabbar <aj...@gmail.com>:
> Hello all,
>
> I'm trying to create a url I can embed in an email using the following
>
> List<String> p = new ArrayList<String>();
> p.add(emailAddress);
> p.add(password);
> Link link = resources.createPageLink("Register", false,
> p.toArray());
> //emailVerifier.sendVerification(user,
> requestGlobals.getHTTPServletRequest().getPathInfo() +link.toURI());
> System.out.println("url is
> "+requestGlobals.getHTTPServletRequest().getPathInfo()
> +"/"+link.toURI());
>
> the value of the System.out.println is
> "url is null/register/username/password"
>
> How do I get the name and port of the web server?
>
> --
> Thanks
>
> A Jabbar Azam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com