0

I am using google app engine to develop my software's backend using java along with Restlet framework. I have index.jsp under my war directory which I want to treat as default page when somebody goes to my website(e.g. example.com). So I have mentioned it under welcome-file-list section in web.xml.

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Also, I have my Restlet servlet mapped to "/*" in web.xml.

<servlet-mapping>
    <servlet-name>RestletServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

But the problem occurs here, because even the call to default page i.e. example.com, also goes to the restlet which obviously doesn't find the mapping in its router. So I decided to instead map restlet servlet to "/restlet/*".

<servlet-mapping>
    <servlet-name>RestletServlet</servlet-name>
    <url-pattern>/restlet/*</url-pattern>
</servlet-mapping>

But with this I get the HTTP 404 error because somehow even though web.xml successfully routes the call to restlet, but restlet doesn't find the mapping in this case in its router object. I have obviously changed the mapping in the restlet router to match the new pattern "restlet/*".

router.attach("/restlet/doSomething",DoSomething.class);

It would be really great if someone can help me with this. Following is my complete web.xml:

<servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
        <param-name>org.restlet.application</param-name>
        <param-value>com.mWallet.loyaltyCardCase.LoyaltyCardCaseWebService
        </param-value>
    </init-param>
</servlet>

<!-- Catch all requests -->
<servlet-mapping>
    <servlet-name>RestletServlet</servlet-name>
    <url-pattern>/restlet/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Thanks!

Manas

mabicha
  • 337
  • 2
  • 7
  • 16

2 Answers2

2

You don't need to change the mapping in the restlet router to match the new pattern "restlet/*" because the restlet router will now be considering "example.com/restlet/" as the base url.

So, if you change the router to match "/restlet/doSomething", your actual url will be "example.com/restlet/restlet/doSomething", which obviously will not work.

So, change your restlet routing to:

router.attach("/doSomething",DoSomething.class);
ntsh
  • 759
  • 5
  • 19
0

I did it in my project and its working. i think you forgot to write below code in web.xml

<servlet>
<servlet-name>RestletServlet</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
 <init-param>
    <param-name>org.restlet.application</param-name>
    <param-value>com.wa.gwtamazon.server.RestApi</param-value>
 </init-param>

  <!-- Catch all requests -->
<servlet-mapping>
<servlet-name>RestletServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

and i already answer in this link Restlet API example may will help you.

Community
  • 1
  • 1
Divyesh Rupawala
  • 1,221
  • 8
  • 15
  • Thanks for your response. Actually I have all this code in my web.xml(have added my entire web.xml to my post above). The problem in this case, is that my calls to home page also get redirected to restlet i.e. calls to "www.example.com", whereas I want my index.jsp to be loaded. As I mentioned above I am trying to have index.jsp(or any other html or jsp page) loaded instead of index.html as a default home page of my website. Have you been able to do that in your project ? – mabicha Mar 31 '13 at 11:04