Hi Pyiush,

Your virtual host doesn't allow any domain names. That's why it fails. Use
VirtualHost.getAllowedNames();

You can also use container.getDefaultHost().attach() directly if you prefer,
it is setup to accept all requests.

Best regards,
Jerome  

> -----Message d'origine-----
> De : Piyush Purang [mailto:[EMAIL PROTECTED] 
> Envoyé : jeudi 19 octobre 2006 17:28
> À : [email protected]
> Objet : Running a simple example
> 
> Hi Jerome, 
> 
> I wanted to update my code. Before that in order to comprehend things 
> I started implementing some simple use cases. The following code 
> doesn't work as intended.... I always get a 404 
> 
> 
> public class Playground { 
> 
>     public static void main(String[] args) throws Exception { 
>         Container container = new Container(); 
>         ServerList servers = container.getServers(); 
> 
>         Protocol httpProtocol = Protocol.HTTP; 
>         String ipAddress = "127.0.0.1"; 
>         int httpPort = 8182; 
> 
>         servers.add(httpProtocol, ipAddress, httpPort); 
> 
>         VirtualHost host = new VirtualHost(container.getContext()); 
>         host.getAllowedProtocols().add(httpProtocol); 
>         host.getAllowedPorts().add(httpPort); 
>         host.getAllowedAddresses().add(ipAddress); 
> 
>         //host.attach("", new Restlet() { 
>         host.attach("/something", new Restlet() { 
>             protected void handleGet(Request request, 
> Response response) { 
>                 response.setEntity("Hello World!", 
> MediaType.TEXT_PLAIN); 
>             } 
>         }); 
>         container.setDefaultHost(host); 
>         //container.getHosts().add(host); 
>         container.start(); 
>     } 
> 
> } 
> 
> 
> The commented parts don't work either. 
> 
> Did I miss something here? 
> 
> Cheers 
> Piyush 
> 
> 

Reply via email to