0

double context root

asked 2009-10-27 09:31:19 +0800

stream gravatar image stream
81 3

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?

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2009-10-27 20:28:35 +0800

iantsai gravatar image iantsai
2755 1

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.

link publish delete flag offensive edit

answered 2009-10-27 20:36:12 +0800

tomyeh gravatar image tomyeh
610 1 3
http://blog.zkoss.org ZK Team

updated 2009-10-27 20:43:34 +0800

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)

link publish delete flag offensive edit

answered 2009-11-02 09:29:03 +0800

stream gravatar image stream
81 3

updated 2009-11-02 09:29:21 +0800

Thanks for your replies,
Now I see how to resolve this issue.

link publish delete flag offensive edit

answered 2010-12-18 04:11:34 +0800

SparkySpider gravatar image SparkySpider
444 1 3

updated 2010-12-18 04:16:19 +0800

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

link publish delete flag offensive edit

answered 2010-12-30 22:04:24 +0800

iantsai gravatar image iantsai
2755 1

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.

link publish delete flag offensive edit

answered 2011-04-13 02:24:57 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Tomcat supports Virtual Hosting Now? HoooHooo!

link publish delete flag offensive edit

answered 2011-04-13 04:18:06 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-10-27 09:31:19 +0800

Seen: 1,698 times

Last updated: Apr 13 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More