Embed magnoliaPublic context content into a different web app context

送分小仙女□ 提交于 2019-12-24 10:44:28

问题


We're trying to embed Magnolia-managed content into some of the JSPs of an existing web app. In Tomcat we deployed and set up a magnoliaPublic context that runs along our existing app context (i.e. two different WAR files). In the browser you can access both:

  • http://localhost:8080/app/test.jsp and
  • http://localhost:8080/magnoliaPublic/footer

So, for example, we'd like /app/test.jsp to include a Magnolia page like /magnoliaPublic/footer (just a div). We managed to do it by adding:

<c:import url="http://localhost:8080/magnoliaPublic/footer" />

to /app/test.jsp. This is almost fine, but a relative include would be best:

<c:import context="/magnoliaPublic" url="/footer" />

This latter line throws

The requested resource (/magnoliaPublic/footer) is not available

I suspect this is due to the way Magnolia's filter chain works, though it's set to dispatch INCLUDE and all server/filters/dispatching/* entries have toMagnoliaResources set to true.

Any hint will be appreciated.

Thank you.


回答1:


IMHO this has nothing to do w/ Magnolia and all to do w/ how c:import works.

Did you try to verify that your request reached Magnolia's filter chain at all?

You can do so by enabling request tracking on your app server, inserting proxy in between or simply by adding info.magnolia.debug.DumpHeadersFilter filter in Magnolia's filter chain and observing the log.

HTH,

Jan




回答2:


Tomcat does not allow you to access another Servlet Context by default. I guess that is the reason why your c:import using the context attribute fails.

Tomcat has the crossContext attribute which configures this:

Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.

Source: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html

Enabling crossContext might solves your problem.



来源:https://stackoverflow.com/questions/19572765/embed-magnoliapublic-context-content-into-a-different-web-app-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!