Berthou.com

A french developper blog

Description

Usually in software devellopement we use values liste that we take from “properties”, SQL tables or in the worst case, “in hard codding” in our application.

As many people I had this problem ans I solve it by creating “Tables Memories”. It permits me to limit the access to the database (or file), to low the occupation memory by having just one request of these memories liste, and to simplify my code.

This code is quite old and could be improved (use of the patern singleton instead of a full static classe, synchronize optimisation…). I use this in a huge number of project and I always report these modifications because I don’t have any performance or memories problems.

Fonctions

During the cration of this componant I wanted to have the following functions also I simplify in maximum its use in a JSP page or a Servtel :

  • “Connection” sql connection outside bean
  • Do not reload the data if they are already in memory
  • Load of a liste from a select SQL : loadQuery(…)
  • Load of a list from a values liste : loadListe(…)
  • Read of the description associated to a code (String) : getValue(…)
  • Read of the description associated to a code (Combobox) : getListe(…)
  • Read of the description associated to a code (Radio Bouton) : getRadio(…)

(more…)

  • 0 Comments
  • Filed under: java, OpenSource
  • aTicker – applet

    Description

    aTicker is a simple, free and small Ticker texte scrolling Applet. aTicker runs on all browsers with JDK 1.1x support. (aTicker is free with all source code).
    This applet is available in JDK 1.1x


    Source HTML

    <applet codebase="/jar" archive="applet-aticker.jar" code="com.berthou.applet.aticker.aticker.class" width=220 height=20 mayscript>
    	<param name=file value="s">
    	<param name=cSep value="§">
    	<param name="speed" value="1">
    	<param name="delay" value="30">
    	<param name="local" value="true">
    	<param name="bgcolor" value="13693183">
    	<param name="Font1" value="Verdana, 14, 0, 0">
    	<param name="Font2" value="Verdana, 14, 1, 1220">
    	<param name="s0" value="JavaSide § http://www.javaside.com § _load">
    	<param name="s1" value="Mess 2 § javascript:alert('Salut...') § _script § ?PopupJavascript">
    	<param name="s2" value="berthou-fr § http://www.berthou.com/fr/ § _load">
    	<param name="s3" value="berthou-us § http://www.berthou.com/us/ § _load">
    </applet>
    

    (more…)

  • 0 Comments
  • Filed under: applet
  • JVMine – Minesweeper

    This small applet is a "minesweeper" clone, the goal of the game is very easy, you just have to discover and mark all the mines. To do this you have as option left clic which show you the land (you loose of there is a mine) and right clic which mark a mine (if the case is not discovered).

    For developpers all source code is avaible here

    i have also done a midlet version of this game and I think I am going to propose it to you soon.

    PS : My best score is in expert mode 153 sec.

    (more…)

  • 0 Comments
  • Filed under: applet, games
  • Servlet : zipservlet

    This article aims at presenting how to create a servlet that sends a zip file to the user. We create here a html page with a form where you can enter an url. The servlet will get the content of this url (only the html page, not the images or other frames), create a zip file with it, and send you the file.
    This example can be used as a basis to do various things.

    • Sending a file with a servlet
      This involves two headers: Content-Type and Content-Disposition. The content type is set to “application/zip”. The other one is used to specify the filename used by the browser when it starts downloading the file.

      res.setContentType("application/zip");
      res.setHeader("Content-Disposition","inline; filename=output.zip;");
      

      This header replace “res.setHeader(“Content-Disposition”,”attachment; filename=output.zip;”);” (not work with IE5)

      In this example, we create a zip file. We’ll discuss later on how to create such files. As soon as we get a byte array with the zip file, we are ready to send it.
      We simply call out.println(zip) to send the file.

    • li>Creating a zip file Have you ever noticed the java.util.zip package ?
      Basically, a zip file is created by adding ZipEntries to a ZipOutputStream.
      Once we have create a ZipEntry with a file name, we are ready to write an array of byte to the ZipOutputStream. Then we close the entry, finish the work with a call to finish(). We finally get a String containing the zipped file.

      zout.putNextEntry(new ZipEntry("file.html"));
      zout.write(b,0,size);
      zout.closeEntry();
      zout.finish();
      String zip=bout.toString();
      

      (more…)

  • 4 Comments
  • Filed under: java
  • 

    Archives



    Recent Comments


    View Berthou Raymond's profile on LinkedIn Add to Technorati Favorites
    Web Developement Blogs - Blog Catalog Blog Directory tlmeb