My gut feeling is that this is something you should configure explicitly. 

You're looking for information that J2EE does not require passing to 
servlets as part of their initialization mechanism, so Restlet has no way 
of knowing this. (There may be a tomcat specific way using attributes 
of the ServletContext or something, but I know of no standard way) 

In a Restlet Component environment where Restlet is controlling the 
servers, you could interrogate the Component's servers and see how 
they are configured, but even in this case you would have to account 
for the fact that multiple Servers can pass requests to the same 
Application, and they can be added or removed at runtime ... which 
sounds like a big undertaking to keep track of. 

----- Original Message ----- 
From: "Richard Bronkhorst" <[EMAIL PROTECTED]> 
To: [email protected] 
Sent: Friday, September 28, 2007 7:33:44 AM (GMT-0500) America/New_York 
Subject: Re: Finding server port from ServerServlet 

Hi thierry, 

Thank you for your response, but that will not work. I am trying to do 
this _before_ any requests come in, in the Application object. I don't 
have a request object at that time. 

Richard 

On 9/28/07, Thierry Boileau <[EMAIL PROTECTED]> wrote: 
> Hi Richard, 
> 
> Can you try : 
> - request.getResourceRef().getHostPort(), 
> - or request.getRootRef().getHostPort(). 
> 
> ("request" is the Restlet request object). 
> 
> best regards, 
> Thierry Boileau 
> 
> 
> On 9/28/07, Richard Bronkhorst <[EMAIL PROTECTED]> wrote: 
> > Hi all 
> > 
> > I am working on a library providing a restlet resource to 'plug into' 
> > other restlet projects. This library does some communication with a 
> > server when the servlet first starts, so before any requests come in. 
> > For this i need to know the port that the application is running on. 
> > 
> > So, for instance, i have a tomcat server running on port 8080, and a 
> > restlet running on top of that using ServerServlet. Is there a way for 
> > the application to find out on which port it is running before any 
> > requests come in? 
> > 
> > Richard 
> > 
> > -- 
> > Richard Bronkhorst 
> > Software Developer 
> > 
> > Noterik BV 
> > P.O. Box 15189 
> > 1001 MD Amsterdam 
> > The Netherlands 
> > 
> > T: +31 (0)20 5929 966 
> > F: +31 (0)20 5929 969 
> > 
> > www.noterik.com / www.noterik.nl / www.streamedit.com 
> > 
> 
> 


-- 
Richard Bronkhorst 
Software Developer 

Noterik BV 
P.O. Box 15189 
1001 MD Amsterdam 
The Netherlands 

T: +31 (0)20 5929 966 
F: +31 (0)20 5929 969 

www.noterik.com / www.noterik.nl / www.streamedit.com 

Reply via email to