samaxes

Icon

on technology

Deploying BIRT Report Engine API with Stripes

Now that I use preferably Stripes over Struts Framework, I’ve decided to port my example “Deploying BIRT Report Engine API with Jakarta Struts” to this Framework.

BIRT WebReport Example

For this example I’ve used Stripes 1.4.2, BIRT Runtime 2.1.2, and Tribix 2.1.2.
Read the rest of this entry »

Secure JSP Taglibs

I’ve just created the project Secure JSP Taglibs at Google Code Project Hosting with the ambition to fill some gaps in the security of the presentation layer in a Java web application.

For now it doesn’t do too much, more features will be added in the future.
This Taglib allows you to evaluate the nested body content of the tag to test if the user has the specified roles.
This is equivalent to the isUserInRole() method, but you can evaluate multiple roles (comma separated) at the same time.

Examples:

1
2
3
<secure:one roles="role1toevaluate, role2toevaluate">
    Show this content if the user has one of the specified roles.
</secure:one>
1
2
3
<secure:all roles="role1toevaluate, role2toevaluate">
    Show this content if the user has all the specified roles.
</secure:all>
1
2
3
<secure:none roles="role1toevaluate, role2toevaluate">
    Show this content if the user has none of the specified roles.
</secure:none>

Feel free to use it, it’s licensed under Apache License 2.0 and can be found at http://code.google.com/p/secure-taglib/.

Comparison between Stripes and JSF

Reading the TheServerSide.COM news I’ve found a comparison’s article between Stripes and JSF frameworks.

I can’t agree more with the author Gregg Bolinger when he says Since I stumbled on Stripes, I’ve found it to be the best all around framework for my purposes.

Read it at “Stripes and JSF: A Brief Comparison“.

Java and UTF-8 encoding

If the J2SE platform has come a long way in internationalization, entering non-ASCII text in the J2EE world isn’t nearly as easy.

To achieve the same result you have to make some changes in your code and in your web server settings.

Firstly, to make sure that the right value in the Content-Type header precedes the text/html content so your browser correctly auto-detects the right encoding, place the following declaration at the beginning of the JSP:

1
<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %>

Next you have to create a filter that implements the ‘javax.servlet.Filter’ interface so you can have the request parameters encoded with UTF-8:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.samaxes.filters;
 
import javax.servlet.*;
import java.io.IOException;
 
/**
 * Filter called before every action.
 *
 * @author : samaxes
 */
public class UTF8Filter implements Filter {
 
    public void init(FilterConfig filterConfig) {
    }
 
    public void destroy() {
    }
 
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain)
            throws IOException, ServletException {
        servletRequest.setCharacterEncoding("UTF-8");
        filterChain.doFilter(servletRequest, servletResponse);
    }
}

Now, your server reads the URL POST parameters correctly…

But there still is an issue - during a GET operation.

The trouble is that none of the charset information gets sent back to the web server during a GET or POST operation. The server has no way of knowing how to interpret the url-encoded GET parameters, so it assumes ISO-8859-1.

Fortunately the solution to address this is pretty simple, just specify URIEncoding="UTF-8" in your Tomcat’s connector settings within the server.xml file.

Your application shall now handle UTF-8 just fine.

Java 6 Final Release Available for Download

The news article from InfoQ:

This morning Sun officially released Java 6 for download after over two years of development. The Java 6 development cycle has been the most open of any Java release with weekly builds available to the public and extensive collaboration between Sun and over 330 external developers. Sun has worked with over 160 companies to ensure backwards compatibility, stability and optimum performance of applications running on the JVM. Java 6 included a number of focus areas. From the press release:

Web 2.0

The Java SE 6 software helps accelerate developer innovation for web-based, dynamic and online collaboration applications by including a new framework and developer APIs to allow mixing of Java technology with dynamically typed languages, such as PHP, Python, Ruby and JavaScript(TM) technology. Sun has also created a collection of scripting engines at: http://scripting.dev.java.net and pre-configured the Rhino JavaScript engine in the Java SE 6 platform. In addition, the Java SE 6 software includes a full web services client stack and supports the latest web services specifications, such as JAX-WS 2.0, JAXB 2.0, STAX and JAXP.

Diagnostics, Monitoring, and Management

The Java SE 6 platform provides expanded tools for diagnosing, managing and monitoring applications and also includes support for the new NetBeans Profiler 5.5 and for Solaris(TM) DTrace, a comprehensive dynamic tracing framework for the Solaris 10 Operating System (OS). In addition, the Java SE 6 software further increases ease of development with tool interface updates for the Java Virtual Machine (JVM (TM)) and the Java Platform Debugger Architecture (JPDA).

Enterprise Desktop

The Java SE 6 release delivers significant improvements to the desktop, which enable Java applications to integrate even more seamlessly into the end-user experience. For rapid visual development of interactive applications, the Java SE 6 platform includes a new layout manager component, based on the NetBeans GUI Builder (formerly code named Matisse). The Java SE 6 software also provides enhanced support for the upcoming version of Windows Vista.

InfoQ discussed the Java 6 release with Bill Curci, Product Marketing Manager for Java Platform Standard Edition and Danny Coward, Java SE Platform Lead. Among the items they highlighted:

A good summary of the main features included in Java 6 can be found in InfoQ’s previous coverage “Top 10 New Things You Need to Know About Java 6“.

BIRT and PHP Reporting

Actuate Corporation and Zend Technologies have teamed up to allow PHP developers to quickly add reporting capabilities to web applications using Actuate BIRT.

The collaboration between Zend and Actuate has resulted in new capabilities in the 3.0 version of the Zend Platform. Zend Platform 3.0 allows PHP developers to quickly integrate reporting capabilities, including charting, to web applications by calling Actuate BIRT reports via the Zend Java Bridge. Web application developers are often faced with strong end-user demands for reports that integrate and summarize application data. This new functionality will provide an efficient alternative to hand coding reports from scratch using PHP, and will ensure that more PHP applications are up and running quickly with the reporting capabilities that they need. Developers who have built reports using Actuate BIRT will now be able to easily distribute those reports via PHP applications.
Functionality that is now available to PHP developers includes:

  • Flexible report output formats that deliver single or multi-page PDF or HTML reports in several viewing and printed formats using parameters, multiple sections, grouping levels, charts, and more. Report content can also easily be exported to CSV format.
  • Reports built on top of any data source that enable report developers to access and generate reports from SQL databases, text files, or XML.
  • Easy-to-use visual design environment that enables developers to create and deploy reports in minutes via a simple, robust, wizard-driven interface.
  • Powerful integrated charting that enables charting reports to be built easily in a variety of types which include Line, Bar, Pie, Meters, Area, Scatter and Stock. The charts can be output in different formats including Scalable Vector Graphics (SVG).

Sun open sources Java under GPLv2

It’s finally here as you can see in Free and Open Source Java.

The key behind moving to the GPL is to drive more volume and more adoption for the platform. The GPL helps get Java into some markets that it hasn’t served as fully as it should - such as educational markets, governments in the developing world, and some commercial customers - as well as, obviously, some distributions of Linux which insist not on Linux-friendly licenses but on actual GPL licensing.

GPLv2 was chosen over GPLv3 for fairly obvious reasons: GPLv3 isn’t finished yet! Sun is, they said, working with the FSF on defining GPLv3.

Read the complete news.

Apache Struts 2 development build

The first development build (2.0.1) of Apache Struts 2 project has been released.

From Planet Struts News:

Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts 2. This new version of Struts is designed to be simpler to use and closer to how Struts was always meant to be. Some key changes are:

  • Smarter!
    • Improved Design - All Struts 2 classes are based on interfaces. Core interfaces are HTTP independent.
    • Intelligent Defaults - Most configuration elements have a default value that we can set and forget.
    • Enhanced Results - Unlike ActionForwards, Struts 2 Results can actually help prepare the response.
    • Enhanced Tags - Struts 2 tags don’t just output data, but provide stylesheet-driven markup, so that we can create consistent pages with less code.
    • First-class AJAX support - The AJAX theme gives interactive applications a significant boost.
    • Stateful Checkboxes - Struts 2 checkboxes do not require special handling for false values.
    • QuickStart - Many changes can be made on the fly without restarting a web container.
  • Easier!
    • Easy-to-test Actions - Struts 2 Actions are HTTP independent and can be tested without resorting to mock objects.
    • Easy-to-customize controller - Struts 1 lets us customize the request processor per module, Struts 2 lets us customize the request handling per action, if desired.
    • Easy-to-tweak tags - Struts 2 tag markup can be altered by changing an underlying stylesheet. Individual tag markup can be changed by editing a FreeMarker template. No need to grok the taglib API! Both JSP and FreeMarker tags are fully supported.
    • Easy cancel handling - The Struts 2 Cancel button can go directly to a different action.
    • Easy Spring integration - Struts 2 Actions are Spring-aware. Just add Spring beans!
    • Easy plugins - Struts 2 extensions can be added by dropping in a JAR. No manual configuration required!
  • POJO-ier!
    • POJO forms - No more ActionForms! We can use any JavaBean we like or put properties directly on our Action classes. No need to use all String properties!
    • POJO Actions - Any class can be used as an Action class. We don’t even have to implement an interface!

Struts 2 key features

  • A flexible, plain old Java object (POJO)-based architecture to structure your code and pages, yet stay out of your way.
  • A theme-enabled tag library supporting JSP, Velocity, and Freemarker.
  • Built in support for complex Javascript and Ajax widgets.
  • A simple plugin framework to integrate with third-party libraries like JavaServer Faces, JasperReports, and JFreeChart.
  • Built-in debugging tools supporting profiling, problem reports, and interactive object model queries.
  • Automatic portlet support allowing portal and servlet deployments with no code changes
  • Quick start development tools like Maven archetypes, automatic reloading configuration files, and bootstrap tutorials.

Other Resources

Eclipse RCP to Cellphones

Great news for embedded devices developers.
Eclipse has recently released the embedded Rich Client Platform (eRCP) 1.0.

eRCP is for J2ME what RCP is for the desktop, and includes among other things

  • Eclipse Core which provides OSGI and Extension Point Framework support
  • a version of SWT called embedded Standard Widget Toolkit (eSWT)
  • eJFace a set of classes which enable eRCP applications to integrate with an eRCP workbench, and provide more complex widgets like MVC oriented viewers
  • eUpdate for dynamically updating device software
  • and microXML a smaller, faster XML parser supporting SAX and DOM API

eRCP currently support Windows Mobile 2003/5.0, Symbian S60/S80, and QT embedded devices.

Alfresco and Web Content Management

A while back (May 24th) I’ve written a post trying to explain what was Alfresco, and some misunderstands about it.

At that time Alfresco wasn’t yet a full Web Content Management system. But that is about to change starting at Release 1.4.

I think it may worth the shoot…

Related Links

Alfresco Wiki

Alfresco Forum

Other

About

samaxes is the personal site of Samuel Santos, a professional web developer living in Coimbra, Portugal. This site is a simple portal for information about technology and software development, focusing on Java technologies, Open Source and Web Standards.

Archives