配置Restlet以在Google App Engine上返回JSP? [英] Configure Restlet to Return JSPs on Google App Engine?

查看:99
本文介绍了配置Restlet以在Google App Engine上返回JSP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个Restlet应用程序。我想通过Restlet在URL请求上返回一个JSP文件。如何在不使用重定向的情况下实现这一目标?




比方说,我在mydomain.com上有文件contact.jsp,我希望人们能够访问 http://mydomain.com/contact



因此,在Restlet中,我将拥有:

  router.attach(/ contact,MyResource.class); 

但是,如何返回contact.jsp页面?我知道重定向会起作用,但我不希望用户看到 http:/ /mydomain.com/contact.jsp 或者是否有另一种策略可以在没有使用restlet的情况下运行?也许对我的web.xml文件进行一些修改?



编辑(2009-08-14):



我的下面发布的答案在App-Engine和Restlet上无效。但是,如果我不包含Restlet,或者允许Restlet具有/ *的url模式,那么它确实有效。



最理想的是拥有一个允许我这样做的路由器的子类:
$ b $ $ p $ router.attach(/ contact,/contact.jsp );

谢谢!

编辑(2009- 08-17):

我很惊讶自从发布奖金以来,我一直没有任何回应。有人发表评论,并让我知道,如果我的问题/问题不明确?

编辑(2009-08-17):



有趣的观察。使用下面Rich Seller中描述的方法时,它在部署在Google App-Engine上时不起作用。另外,如果我在Google App-Engine上调用 http://mydomain.com/contact.jsp ,它会绕过Restlet并直接进入JSP。但是,在当地,Restlet接管了。也就是说, http:// localhost:8080 / contact.jsp 不会转到JSP并转到的Restlet。部署的应用程序引擎应用程序对URL的响应方式与其本地对应方式有所不同吗?

我想在通过Restlet的URL请求 - 我的理解是将JSP的转换为servlet。由于Servlet与Restlet是正交的,因此不知道如何通过Restlet返回JSP文件。



假设您要求使用除Restlet之外的JSP的方法,这是最好的通过将你的restlets映射到一个根路径(比如/ rest而不是/ *)并像往常一样使用.jsp来实现。

I have a developed a Restlet application. I would like to return a JSP file on a URL request through Restlet. How can I achieve this without using a redirect?

i.e. Let's say I have the file "contact.jsp" on mydomain.com and I want people to be able to access contact.jsp at http://mydomain.com/contact

Thus, in Restlet, I would have:

router.attach("/contact", MyResource.class);

But how can I return the "contact.jsp" page? I know that a redirect would work, but I don't want users to see the ".jsp" in "http://mydomain.com/contact.jsp"... or is there another strategy that would work without even using restlet? Maybe some modification of my web.xml file?

Edit (2009-08-14):

My answer posted below doesn't work on App-Engine and Restlet. It does work however, if I don't include Restlet, or allow Restlet to have a url-pattern of "/*"

What would be ideal is to have a subclass of the Router that allows me to do this:

router.attach("/contact", "/contact.jsp");

Thanks!

Edit (2009-08-17):

I'm surprised I haven't had any responses since I posted a bounty. Will someone comment and let me know if my question/problem isn't clear?

Edit (2009-08-17):

Interesting observation. When using the method described by "Rich Seller" below, it works when deployed on Google App-Engine and not locally. Additionally, If I call http://mydomain.com/contact.jsp on Google App-Engine it bypasses Restlet and goes straight to the JSP. But, locally, Restlet takes over. That is, http://localhost:8080/contact.jsp does not go to the JSP and goes to Restlet. Do deployed app-engine applications respond differently to URLs as their local counterpart?

解决方案

"I would like to return a JSP file on a URL request through Restlet" - My understanding is JSP's are converted to servlets. Since Servlets are orthogonol to Restlets not sure how you can return JSP file through Restlet.

Assuming you are asking for a way to use JSP in addition to Restlet, This is best achieved by mapping your restlets to a rootpath such as /rest instead of /* and using the .jsp as usual.

这篇关于配置Restlet以在Google App Engine上返回JSP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆