OGNL and Struts
Though I like JSTL I am sometimes missing the feature to call methods. Therefore I have played around a little bit with OGNL and Struts actions and I am very happy with the result. I have written a JSP tag that allows you to execute an OGNL expression. Furthermore I have extended my RequestProcessor once again. Now the action instance is visible to the OGNL tag as well. This allows me to call a method on the action from the OGNL tag! A sample JSP page might look like this:
<ognl:property value="formatTime(#created)"/>
Thoughts about caching with Struts Actions, Tiles and JSP
Talking to the database on each request is not necessary because the content of my weblog does not change very often (for now =) ). So I like the idea of using a cache. Whenever I add a new entry I could send a notification to the cache and the cache would be flushed. So far so good. The tricky thing now is that I am using Tiles and putting a cache taglib into the tile would have no effect because the correspondig Action, which talks to the database, would still get called. Therefore I need a cache logic before the Action gets called. Currently I think the best solution would be to write a special filter. The filter would cache a defined URL, e.g. http://woeye.highteq.net/weblog/show.do?author=woeye and flush the cache on special events. Perhaps I should take a look at OSCache from OpenSymphony?
Any ideas or suggestions?
Writing into multiple files with log4j
Using log statements for low-tech debugging is generally a good thing. Using only one file however may become chaotic especially if you want to trace third party frameworks as well. I faced the problem during the development of my system. When I set the threshold in log4j to DEBUG my logfile was exploding (Struts and Tiles are very talkative).
Thanks to log4j it is possible to use different files for different packages (and their children). First you have to declare the appenders you want to use, e.g. an appender called HIBERNATE:
<appender name="HIBERNATE" class="org.apache.log4j.FileAppender">
<param name="Append" value="false"/>
<param name="File" value="${server.home}/logs/log4j-hibernate.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>
Afterwards you can attach a category to these appenders. This way you can log all statements from Hibernate into one log file, all statements from Struts into another log file and so on:
<category name="cirrus.hibernate"> <priority value="DEBUG" /> <appender-ref ref="HIBERNATE"/> </category>
Minor JavaScript bug fixed
The comment link was broken on Mozilla. Thanks to JavaScript guru pulsar this nasty bug was easy to fix.
Roll the drums
After some weeks of hacking I finally replaced the backend of my little website. The new version is based on 100% pure Java technologie. Actually I wanted to learn about all those new cool frameworks such as Jakarta Struts, Hibernate, Jakarta-Commons, JSTL, EJB and so on. I ended up with an entire rewrite of the old backend. In fact my new backend has a lot of more features such as news, weblogs, comments, private messages and profiles. This page, however, only uses the weblog feature currently. I am working with some friends on a new project which will be based on my new system. You may ask which project? Well, stay tuned =) I will release the source under an open source license and perhaps even host it on sourceforge.net. Currently we are searching for a nice name. Suggestions?