click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rakesh_bhalke <>
Subject URL Rewirting
Date Wed, 07 Dec 2011 05:43:57 GMT

Click JSImport and CSImport by default appends the context to the js and css
files. This causes issues in URL rewirting as follows

Lets say i have 1 application to be deployed for 3 customers. Each on these
is deployed on seperate tomcat instances. Hence the URL for each application
will look like this


Now if my http server is front ending these tomcats then my URL rewrite will
be as  pointing to http://internalip:8080/TestApp/  pointing to http://internalip:8081/TestApp/  pointing to http://internalip:8082/TestApp/

Now if we see the html generated by click, it is 

 because of which URL rewriting fails.

Our analysis is as follows

Following code from JsImport which add context path in js file url.

public void setSrc(String src) {
        if (src != null) {
            if (src.charAt(0) == '/') {
                Context context = getContext();
                String contextPath = context.getRequest().getContextPath();

                // Guard against adding duplicate context path
                if (!src.startsWith(contextPath + '/')) {
                    HtmlStringBuffer buffer =
                        new HtmlStringBuffer(contextPath.length() +

                    // Append the context path
                    src = buffer.toString();
        setAttribute("src", src);

Our suggestion is to not append the context and to create a relative path
for JS and CSS imports.

View this message in context:
Sent from the click-development mailing list archive at

View raw message