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