Archive for category Tricks
Deploy your app to the root context
This is an easy trick which I am sure most of you already know.
Let’s take a Java application called MyAddressBook. Its generated war file could be called myaddressbook.war
.
By default, when you deploy this web application to Tomcat, the URL to access it will be http://localhost:8080/myaddressbook/. And if you point a domain name such as ‘addressbook.com’ to this server, the URL would be http://addressbook.com/myaddressbook/.
I don’t know for you but I don’t like to systematically have the subfolder ‘myaddressbook’ after my domain. But maybe I am too picky! 😉
The idea is to deploy our application in the Tomcat root context.
You have two ways of doing this:
- Define a
ROOT.xml
file in yourconf/Catalina/localhost
folder, or; - Rename your war file to
ROOT.war
.
Note that the case is important, it has to be ROOT in UPPERCASE! 🙂
Once this is done, you will be able to call your application via the URL http://localhost:8080/
or http://addressbook.com/. Way better! 😎
Be careful of SKIP_COMMENTS
Posted by smoreau in Tricks on 01 Dec 2009
In the early days, we used to hide JavaScript code from old browsers that do not support JavaScript.
The way of doing this was to put a one-line HTML-style comment without the closing characters immediately after the opening
<script>
tag and put//-->
at the end of the script.For example:
However if you are using this trick with the initialization parameter
facelets.SKIP_COMMENTS
set to true, the code between<!--
and//-->
won’t even be sent to the client!It simply means that the code above won’t open an alert window because it has been skipped during the page rendering.
Here is what the client will receive:
You have two solutions to avoid this situation:
SKIP_COMMENTS
parameter to false (the default is true). This can’t really hurt, your page will just be heavier depending on how much HTML comments you put on your page;For information, below is the code to put in your web.xml file to set the
SKIP_COMMENTS
parameter to false:Facelets, JavaScript, old browsers, SKIP_COMMENTS
No Comments