Embed magnoliaPublic context content into a differ

2019-08-02 13:18发布

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.

2条回答
乱世女痞
2楼-- · 2019-08-02 13:57

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.

查看更多
\"骚年 ilove
3楼-- · 2019-08-02 14:01

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

查看更多
登录 后发表回答