tinkerwell / jodd

Automatically exported from code.google.com/p/jodd
0 stars 0 forks source link

Stapler file path is wrong when web application has non empty context #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I think I found one more potential bug, but you should confirm.

When web application has a non empty context path (e.g. /mywebapp), HTML 
stapler is looking for the resource files (JS and CSS) under the folder 
<docroot>/mywebapp/.../

I think that this is wrong and that it should first strip out context path so 
that the local file system path is <docroot>/.../.

Original issue reported on code.google.com by bandino....@gmail.com on 17 Apr 2012 at 5:59

GoogleCodeExporter commented 9 years ago
Huhm u think i put this on purpose;) I will check it our again and let you know 
;)

Original comment by igor.spasic on 17 Apr 2012 at 9:03

GoogleCodeExporter commented 9 years ago
Ok, here is an example that works for me when application is deployed under 
"/madvoc" servlet context.

http://code.google.com/p/jodd/source/browse/trunk/mod/serverside/web/js.jsp
http://code.google.com/p/jodd/source/browse/trunk/mod/serverside/web/stapler/js.
jsp

both pages work the same when deployed at root or under some context path.

can you check if this works for you, please?

Original comment by igor.spasic on 17 Apr 2012 at 9:48

GoogleCodeExporter commented 9 years ago
Hi Igor,

I think that the issue is there, even in the samples you mentioned above.

Let us say that for our example application context path is /myapp.
The following line, from one of your sample pages: 

<script type="text/javascript" src="/jquery.tooltip.js"></script>

will work perfectly well with stapler. However, if you turn off the stapler 
(which is standard way and should not break anything), you will see that 
browser is getting the 404 response. That is because it tries to fetch the URL 
http://localhost:8080/jquery.tooltip.js

instead of 

http://localhost:8080/myapp/jquery.tooltip.js.

So, the correct script reference would be:
<script type="text/javascript" src="/myapp/jquery.tooltip.js"></script>

That is exactly the URL the <c:url> would produce - it would prepend the 
context path.

However, that later script reference will produce stapler exception:
Can't create bundle.; <--- java.io.FileNotFoundException: Not found: 
C:\projects\jodd-jetty\docroot\myapp\jquery.tooltip.js.

I hope this will help.

BTW, JODD is great framework, I am glad to help in resolving these minor issues 
so it becomes even better. Great work.

Original comment by bandino....@gmail.com on 18 Apr 2012 at 8:29

GoogleCodeExporter commented 9 years ago
Haaaa, i've made example work with invalid html/css;)

thank you, i'm just about to fix it, need to remove context path when creating 
local path.

and glad you like JODD :)

Original comment by igor.spasic on 18 Apr 2012 at 1:29

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1069.

Original comment by igor.spasic on 18 Apr 2012 at 1:31