Oracle bought Sun Microsystem

Big shopping in the Silicon Valley

Oracle purchase SUN for 7,4 billion
OK! My Sun certifications become Oracle certification! Dho!

Custom 404 with jsp

First of all, you've to insert in the web xml this lines:

<error-page>
<error-code>404</error-code>
<location>error.jsp</location>
</error-page>


In this way tha application server when doesn't find a resource it will pass the ball to the error page.
When the server forward to the error page it passes same attribute in the request, like:

Attribute

Type

javax.servlet.error.status_code

java.lang.Integer

javax.servlet.error.exception_type

java.lang.Class

javax.servlet.error.message

java.lang.String

javax.servlet.error.exception

java.lang.Throwable

javax.servlet.error.request_uri

java.lang.String

javax.servlet.error.servlet_name

java.lang.String


It will be enough, in the error page, to show something a message like this:
The requested reource <%=request.getAttribute("javax.servlet.error.message")%> has not be found!

Obviously, the same things are valid for the others HTTP errors, like 500, 400, and so on.

How lookup the world in different langauges

This time we speak about the lookup service.
Why? because the problem is this: i have a datasource, say "jdbc/gifaDS". I installed this datasource in Tomcat, in JBoss and finally in Oracle Ias 10g.
I will not speak about how to define a datasource in the above application servers, but how to lookup them!
Yes, because the jndi service is different in every application server.
In poor words:
  • with Tomcat: java:comp/env and after the datasource name, so: java:comp/env/jdbc/gifaDS
  • with JBoss: only java:, so: java:/jdbc/gifaDS
  • with Oracle Ias 10g: no prefix, so: jdbc/ConanDS

web.xml warning "CHKJ4019W: Invalid res-sharing-scope; valid values are "Shareable" or "Unshareable"

what?
I have this warning from vary vary time ago. And only today i decided to investigate.
And i find a solution: adding a res-sharing-scope tag inside the resource-ref tag, and exactly:


<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/DB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Error Messages with JSF

If your method throws an exception or, more generally, there is a controlled error or warning and you must show to user this error then you can add a FacesMessage in your JSF page in this way:

try {
yourCode...;

}
catch (YourApplicationException e) {
FacesMessage messaggio=new FacesMessage(e.getMessage());
FacesContext context=FacesContext.getCurrentInstance();
context.addMessage(null,messaggio);
return null;
}

In your jsp page you have to add this code:

<h:messages globalOnly="true" />

The globalOnly attribute because it will display all generic error messages, those messages with the first parameter of addMessage method equals to null.
If you want display errors about a single field the you must specify the "validator" attribute of that field!

Theoretically, you could specify the id field in the first parameter of "addMessage" method but with JSF 1.1 seems not work!

IBM wants Sun

IBM is buying Sun! It's not a done thing, but it seems that it will do. The price is astronomic: $6.5 billions.
I ask my self: what will be my SCEA certification: it will became ICEA certification?

Keep things together

This time i will explain a functionality of xsl-fop: "keep-together" attribute.
In a pdf page (report), that is created by xsl-fop, i don't want that a block is split between page, if it doesn't enter completely in one page. So the solution is add the keep-together attribute in the fo:block, and more specifically this is the right attribute: keep-together.within-page="always".
In this case (within-page) the block is not split between two different pages, but the block is written all in the next page.