Guess I am a bit confused in how Application application = new Application
and InboundRoot and Restlet all relate. Should I have nested the Restlet
inside the Application like this:?
Application application = new Application(this.getContext()){
@Override
public Restlet createInboundRoot(){
Router router = new Router(this.getContext());
Restlet mainpage = new Restlet(){
@Override
public void handle(Request request, Response
response){
StringBuilder stringBuilder = new
StringBuilder();
stringBuilder.append("<html>");
stringBuilder.append("<head><title>Default
Page of my TEST
application</title></head>");
stringBuilder.append("
Click on link
");
//stringBuilder.append(" ");
stringBuilder.append(" <\"/file\">
</html>");
response.setEntity(new StringRepresentation(
stringBuilder.toString(),
MediaType.TEXT_HTML));
}
};
router.attach("", mainpage);
return router;
}
component.getDefaultHost().attach(application);
component.start();
}
Or am I missing some major / subtle point here ?
Thanks for the help in advance
On Thu, Aug 7, 2014 at 11:05 PM, Tim Peierls [via Restlet Discuss] <
[email protected]> wrote:
> Looks like you're attaching a vanilla Application instead of an instance
> of PageTest.
>
>
> On Thu, Aug 7, 2014 at 3:39 PM, Shai Levit <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=7579257&i=0>> wrote:
>
>> Hi Tim,
>> Thank for the insight and so I am working on adding more complexity. So
>> here
>> is a simple code that should work, but for some reason I get this error:
>> The filter org.restlet.engine.application.RangeFilter@24f2f2 was executed
>> without a next Restlet attached to it.
>> 2014-08-07 15:37:47 0:0:0:0:0:0:0:1 - - 8400
>> GET / - 500 486 0
>>
>> The full code is as follows:
>>
>> package org.simpler.test;
>>
>> import org.restlet.Application;
>> import org.restlet.Component;
>> import org.restlet.Request;
>> import org.restlet.Response;
>> import org.restlet.Restlet;
>> import org.restlet.data.MediaType;
>> import org.restlet.data.Protocol;
>> import org.restlet.representation.StringRepresentation;
>> import org.restlet.routing.Router;
>>
>> public class PageTest extends Application {
>>
>> public static void main(String[] args) throws Exception {
>>
>> Component component = new Component();
>> component.getServers().add(Protocol.HTTP, 8400);
>>
>> Application application = new Application();
>>
>> component.getDefaultHost().attach(application);
>> component.start();
>>
>> }
>>
>> @Override
>> public Restlet createInboundRoot(){
>>
>> Router router = new Router(this.getContext());
>>
>> Restlet mainpage = new Restlet(){
>> @Override
>> public void handle(Request request, Response
>> response){
>> StringBuilder stringBuilder = new
>> StringBuilder();
>> stringBuilder.append("<html>");
>>
>> stringBuilder.append("<head><title>Default Page of my TEST
>> application</title></head>");
>> stringBuilder.append("
>> Click on link
>> ");
>> //stringBuilder.append(" ");
>> stringBuilder.append(" <\"/file\">
>> </html>");
>>
>> response.setEntity(new
>> StringRepresentation(stringBuilder.toString(),
>> MediaType.TEXT_HTML));
>> }
>> };
>>
>> router.attach("", mainpage);
>> return router;
>> }
>>
>> }
>>
>>
>>
>> --
>> View this message in context:
>> http://restlet-discuss.1400322.n2.nabble.com/Complexity-in-understanding-tp7579254p7579256.html
>> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------
>>
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3086393
>>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://restlet-discuss.1400322.n2.nabble.com/Complexity-in-understanding-tp7579254p7579257.html
> To unsubscribe from Complexity in understanding, click here
> <http://restlet-discuss.1400322.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7579254&code=QXJjdGlrem9uZUBnbWFpbC5jb218NzU3OTI1NHwtMTA1NDg3NjEzMw==>
> .
> NAML
> <http://restlet-discuss.1400322.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context:
http://restlet-discuss.1400322.n2.nabble.com/Complexity-in-understanding-tp7579254p7579258.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3086428