質問

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

役に立ちましたか?

解決

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);

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top