Large File Downloads with JBoss Seam 2 and Servlets

Today I worked an an issue which presented users of our application a 403 error page when downloading large files which were generated on the fly. The files were delivered by a servlet and the files were directly copied to the ServletOutputStream, so the files were streamed instead of holding them in memory.

After some debugging it turned out, that the files were not streamed since the Seam Ajax4JSF Filter doesn’t allow to stream files and this resulted in OutOfMemoryExceptions. There are a few ways how to disable or extend the Ajax4JSF Filter (see this Seam Forum Thread).

Since all our download resources are mapped to servlets which resides in the „/media/*“ path, it was pretty easy to just enable the Ajax4JSF Filter for all paths except the „/media/*“ paths. To achieve this, just add to your components.xml:

<web:ajax4jsf-filter regex-url-pattern="^(?:[^/]|/(?!media/))*$"/>

Different ways to redirect with JSF and Seam

This is just a quick reminder for myself how to implement programmatic redirects with JBoss Seam and JSF.

I will describe three different techniques:

  • Redirecting to a 404 Error Page from a JSF Backing Bean
  • Redirecting to an external Website
  • Redirecting to a JSF view in a Seam Application

Weiterlesen

Allowed Characters for Javascript Variables

I am playing with the JDK Javascript API (JSR 223) and I wanted to check out the replacement of variables in a String. Then I suddenly got this error:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (<Unknown source>#1) in <Unknown source> at line number 1

After some reseach I found out, that my variables did contain invalid characters in my case the variable contained a .

So the Regular Expression for valid Javascript variable names is:

[a-zA-Z_$][0-9a-zA-Z_$]*

It is also possible to use any unicode characters for variables, but of course this is not recommended.

Add Path Bookmarks to iTerm

Since I am a developer, I need a terminal very often. I prefer using on my MacOSX System. I use many tabs in iTerm and obviously all terminals point to different locations. I was tired of switching to all relevant locations everytime I start up iTerm. So I decided to give the bookmark feature of iTerm a try.

My goal was to just click on a bookmark and a new tab should appear which has the right folder as default workspace.
Weiterlesen

Ordnerbilder für Fastgallery Gallerien in Drupal

Ich nutze seit geraumer Zeit für eine DrupalInstanz Fastgallery um Bildergallerien auf dieser Drupal Webseite zu realisieren. Das Modul ist recht nützlich, wenn man viele Bilder hochladen will, jedoch auf Features wie Kommentare, Bewertungen oder Ähnliches verzichten kann.

Es hat mich jedoch schon immer ein bisschen gestört, dass bei jedem Upgrade das Modul nicht mehr wirklich abwärtskompatibel ist und ich deshalb schon öfter meine Backups einspielen musste weil es mir dann meine Bildergallerien zerschossen hat :)

Ein Feature was ich bei den alten Version spitze fand ist, dass man Bilder als Gallerieordnerbilder verwenden konnte. Ich dachte immer, dass das Feature verschwunden ist, mit ein bisschen mehr Aufwand geht das ganze jedoch doch:
Weiterlesen

Maven Projekt mit JDK 1.6 kompilieren

Die Standard Compiler Einstellung für Maven ist das JDK 1.4 . Da sogar Java 1.5 das End of Life schon lange erreicht hat, wollen die meisten ihr Projekt wohl mit Java 1.6 kompilieren.

Um Maven dazu zu bringen das JDK 1.6 zum kompilieren, benutzt man einfach das maven-compiler-plugin. Hier ein Beispiel aus meiner pom.xml:

Weiterlesen

Secure the Ntop Webinterface

By default only a few areas of the ntop webinterface have restricted access. To secure the whole ntop webinterface follow these instructions:

  1. Navigate to „Admin -> Configure -> Protect URLs“.
  2. Click „Add URL“.
  3. Leave the field empty and klick „Add URL“

Now your whole webinterface of ntop is secured and only your defined users have access to the webinterface.

Pixture_reloaded CCS Theming

Today it took me the whole day to check out this small dirty trick:

If you are using the Drupal Theme Pixture Reloaded, all changes in your style.css are not applied automatically. Like every other Drupal Theme, which supports the Colour Module, you have to klick „Save Configuration“ in your theme configuration dialog. Only after klicking it, your style.css gets read out. Otherwise your old cached css file is used.

After that i had another problem: My Theme was broken after reading the style.css out. I just had to delete the /sites/default/files/color folder and everything worked fine again.

XAMPP: Apache doesn’t start

If you want to start Apache via XAMPP, but it won’t start, most likely another application listens to port 80. Very often this „problem-application“ is Skype. There are two possible approaches:

  1. You start Apache before you start the Skype client.
  2. You deactivate Skypes feature to listen to port 80 and 443. You can do this via the settings dialog. Just uncheck „Use port 80 and 443 as alternatives for incoming connections.

Now everything should be fine.