Categories java

How to remove the blank line in JSP left by the directive

The blank line after JSP directive issue has been tackled from JSP 2.1 version and above. To sort this thing out just set the property trimDirectiveWhitespaces="true" which is set to false by default.... Read More

How to print all elements in a Map

To get just the key... Read More

How to Put all the values of a resultset to a bean with BeanProcesor

BeanProcesor is an Apache API that helps us copy all the values from a Resultset to a bean. It uses reflection and unless you need an extremely optimal code it highly recommended to uses because it reduces development time.... Read More

Servlet example that forces an mp3 to be downloaded, not to be played

Sometimes we may need to use a servlet to download mp3 files or other files not to play them or reproduce them. Most browsers understand the application/force-download content type header which does the trick.... Read More

How to get the linux distribution information from Java

There are many ways of getting the linux distribution in Java. Here you can find some examples that may suit your needs.... Read More

Handle System.err and System.out with Java Examples

In java the three main Streams stdin (standard input) , stdout (standard output) and stderr (standard output error) are handled by default by System.in, Sytem.out and System.err respectively. Sometimes we may need to change the output according to our needs, this can be done in many ways such us using the OS to tell what stream we need to use or using java to set what streams we want to be used.... Read More

How to Override or Add a new protocol to the java.net.URL and changing FTP

If you use java.net.URL to load url and in some cases you want to add a new protocol or if you want to use another API to handle certain protocols it is possible to do it. In this example I'm overriding the FTP protocol so that it is handled by the org.apache.commons.net.ftp.FTPClient API... Read More

Load URL with Java Sockets

This example shows how to connect to an URL using just java sockets. You may want this for a number of reasons.... Read More

CommunicationsException with Java and MYSQL

I wrote this post to show I solve this exception. There are a number of reasons why this error may come up and there is not a universal solution for all cases. Perhaps your are not using the same technology as me but you can find some clues here that may help you find a solution.... Read More

Basic Example of Persistence with Java

Sometimes we may need to save our objects out of the RAM scope. The act of storing  objects outside the RAM is called persistence.... Read More