-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi to All,
I am integrating ZK 5 to my web application that works in the intranet through Apache Proxy Server. There is the issue concerning context root. When context is double (e.g. 'http://host:port/env/env2/....') the problem occurs:
there is the generated code by ZK5.
...
<link rel="stylesheet" type="text/css" href="/env2/zkau/web/zul/css/zk.wcs"/>
<script type="text/javascript" src="/env2/zkau/web/js/zk.wpd" charset="UTF-8">
</script>
<script type="text/javascript" src="/env2/zkau/web/js/zul.wpd" charset="UTF-8">
</script>
<!-- ZK 5.0.0-RC 09100212 -->
<script>zkopt({kd:1});
...
As you can see all urls contain '/env2' context instead of '/env/env2'.
How could I resolve this issue?
To Tomcat service the Apache context is transparent, contained application shouldn't know anything about the proxy.
Because if that is correct, then every time you changed your context, every application behind it should be restructured, and it's ridiculous.
I think using virtual host(request forward) would be better.
May I know how do you configure to have "/env/env2"? And, the Web server considers the context as "/env2", right?
ZK retrieves the context from the Web container. If Apache is configured to prefix with another context (such as /env), ZK has no idea to know. In most cases we know, it can be avoided (such as Ian's suggestion of using virtual host). If it is what you really want, you can implement an interfaced called org.zkoss.web.servlet.http.Encodes.URLEncoder. Refer to Encodes.encodeURL for details. (Regarding this feature, it is better to ZK 5 freshly since there is some enhancement)
Thanks for your replies,
Now I see how to resolve this issue.
Hi Tomyeh, Stream,
I didn't quite understand your solution.
Please can you explain what you did to solve this problem more clearly.
I have an application in a context "www.myserver.com:8080/context", but use a domain www.context.com that uses ProxyPass and ProxyPassReverse. All my resources now point to /context/resource (which is obviously wrong).
1. Are you guys using ModRewrite to strip off the /context (messy)?
2. Do you think I could use a base HREF tag?
3. Is there a way that we can tell ZK *not* to use the context.
Thanks,
Mark
Sorry, the context is defined by Java Web Container, not ZK, if you don't want context name in your application, you need to make your Web project as the default context of your container(ex: ROOT to Tomcat).
If you have multiple Apps in same container, you can use virtual host to separate it.
Tomcat supports Virtual Hosting Now? HoooHooo!
Hi,
Tomcat as well as Jetty are supporting virtual hosting:
http://jease.org/coffeeklatsch/multiple_sites
I'm using it a lot and it works like a charm.
Cheers, Maik
Asked: 2009-10-27 09:31:19 +0800
Seen: 1,698 times
Last updated: Apr 13 '11