<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.9.2 (http://www.squarespace.com/) on Thu, 11 Mar 2010 16:10:31 GMT--><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:cc="http://web.resource.org/cc/"><rss:channel rdf:about="http://www.glennbech.com/home/"><rss:title>java</rss:title><rss:link>http://www.glennbech.com/home/</rss:link><rss:description></rss:description><dc:language>en-US</dc:language><dc:date>2010-03-11T16:10:31Z</dc:date><admin:generatorAgent rdf:resource="http://www.squarespace.com/">Squarespace Site Server v5.9.2 (http://www.squarespace.com/)</admin:generatorAgent><rss:items><rdf:Seq><rdf:li rdf:resource="http://www.glennbech.com/home/2009/9/10/using-the-jersey-10-client-api-to-update-a-twitter-status.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2009/7/7/not-so-good-exception-handling-at-squarespacecom.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2009/6/28/using-yahoo-pipes-to-keep-everyone-up-to-date.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2009/6/27/getting-started-with-javafx-in-30-minutes.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2009/5/30/httponly-cookies-in-the-servlet-30-specification.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2007/3/13/about-eclipse-and-tekken.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2006/11/6/working-with-jsf-myfaces-javalangillegalstateexception-clien.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2006/10/19/poke-532810.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2006/8/7/more-on-the-bea-81-servlet-filter-requestdispatcher-issue.html"/><rdf:li rdf:resource="http://www.glennbech.com/home/2006/8/3/the-bea-81-servlet-container-implementation-is-causing-probl.html"/></rdf:Seq></rss:items></rss:channel><rss:item rdf:about="http://www.glennbech.com/home/2009/9/10/using-the-jersey-10-client-api-to-update-a-twitter-status.html"><rss:title>Using the Jersey 1.0 client API to update a Twitter status</rss:title><rss:link>http://www.glennbech.com/home/2009/9/10/using-the-jersey-10-client-api-to-update-a-twitter-status.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2009-09-10T16:59:49Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>Jersey 1.0 is an open-source, implementation of JAX-RS, the Java API for RESTful Web Services (JSR-311). Jersey makes it easy to create RESTful web services using Java technology.&nbsp;</p>
<p>Attending JavaZone in Oslo/Norway this year, I had the idea of having an application written as contest at our expo stand tweet whenever somebody won a price, and when the contest was open for business. &nbsp;</p>
<p>Unfortunately I didn't finish the code in time for the expo; but Im sure I can use it next year, if Twitter still is Twitter that is... :-)</p>
<p><a href="http://bechonjava.squarespace.com/storage/java/TweetSender.java">Anyhow, here's the code...</a>&nbsp;Please feel free to use, or abuse it any way you like.</p>
<p>PS.</p>
<p>The code uses Basic authentication instead of the suggested OAuth mechanism. Be warned that you should also consider using SSL with BASIC authentication to avoid theft of your credentials :-)</p>
<div></div>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2009/7/7/not-so-good-exception-handling-at-squarespacecom.html"><rss:title>Not so good exception handling at squarespace.com</rss:title><rss:link>http://www.glennbech.com/home/2009/7/7/not-so-good-exception-handling-at-squarespacecom.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2009-07-07T11:05:44Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p><span class="full-image-block ssNonEditable"><span><img src="http://www.glennbech.com/storage/sqlogo.jpg?__SQUARESPACE_CACHEVERSION=1246966968298" alt="" /></span></span>I use SquareSpace.com for this blog and I am very pleased with the ease of use and service so far. It's also, as far as i know, Java based.</p>
<p>A couple of days back, I got an email warning me that they were unable to bill my credit card. This is an excellent example of what can go very wrong when you mix technical error messages into communication with the customer. Looks like they're having integration problem of some kind in their payment system. Let's all learn from this, and never, ever use the <em>Exception.getMessage()</em> when building messages to a real person.</p>
<p>I'll better write customer service before my blog is taken down.&nbsp;</p>
<p><span style="text-decoration: underline;">Squarespace says; &nbsp;</span></p>
<p><em>"We were unable to apply a charge to your credit card to pay for a past month of Squarespace service for your account at&nbsp;</em><a href="http://bechonjava.squarespace.com/" target="_blank"><em>http://bechonjava.squarespace.com/</em></a><em>.<br /><br />Your credit card transaction failed with the message:<br /><br />Unable to complete transaction. <strong>IO exception: java.net.ConnectException: Connection refused</strong><br /><br />While attempting to process a transaction for:<br /><br />$14.00 - Service fee (monthly) for &lt;strong&gt;bechonjava&lt;/strong&gt; on &lt;strong&gt;Squarespace Pro Package&lt;/strong&gt;<br /><br />To pay this invoice, log into your Squarespace account's website manager and update your billing information under the 'Account' tab. After updating your information, click to pay your unpaid invoice under the 'Billing History' tab.<br /><br />This is your final notice regarding this invoice. If you do not respond to this matter within 3 days, your account will be suspended until the invoice is paid. We reserve the right to remove features, data, and files from suspended accounts in order to regain server storage. Please contact us immediately if you have any questions or concerns regarding this notice.<br /><br />Please note that the resolution of this issue by Squarespace is a human process. No automated system will make a decision on whether or not to deactivate an account or remove data.<br /><br />Thanks again for your attention to this matter."</em></p>
<p>&nbsp;</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2009/6/28/using-yahoo-pipes-to-keep-everyone-up-to-date.html"><rss:title>Using Yahoo Pipes to keep everyone up to date</rss:title><rss:link>http://www.glennbech.com/home/2009/6/28/using-yahoo-pipes-to-keep-everyone-up-to-date.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2009-06-28T09:28:04Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p><span class="full-image-block ssNonEditable"><span><img style="width: 450px;" src="http://www.glennbech.com/storage/Yahoo-pipes-edit-by-Robin-Good-465.jpg?__SQUARESPACE_CACHEVERSION=1246486677837" alt="" /></span></span></p>
<p>Yahoo pipes is a tool you can use to aggregate, manipulate, and mashup content from around the web. With the graphical user interface you can drag and drop inputs and operations into a designer, and connect them graphically.&nbsp;</p>
<p>The output of the pipe can be read as RSS, JSON, KML and other formats as well.</p>
<p>One of the simplest yet &nbsp;powerful uses of it, is to&nbsp;combine multiple RSS feeds into one.</p>
<p>I am now using pipes to...</p>
<ul>
<li>Combine news from InfoQ, TSS, The Aquarium (Sun Glass fish Blog), Ed Burns's blog etc. etc etc. The blogs get piped into a &nbsp;"recommended to read Feed" &nbsp;that tmy collegues can use to keep updated. I download this feed to the Nokia E71 every hour automatically. That way, I always have fresh news to read if I have some spare time. &nbsp;&nbsp;&nbsp;</li>
<li>Combine blogs written by my colleagues, both personal and work-related to encourage sharing of knowledge. &nbsp;This also promotes the blogs and motivates everyone to contribute more.</li>
</ul>
<p>&nbsp;This is only scratching the surface. The Pipes Engine can read CSV files over HTTP, query Google &amp; Flickr, sort, filter and much much more.</p>
<p>Using Yahoo piles in a cool way? Don't hesitate to leave a comment.&nbsp;</p>

<!-- AddThis Button BEGIN --> <a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a4be61c44d1ec52" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a4be61c44d1ec52"></script> <!-- AddThis Button END -->]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2009/6/27/getting-started-with-javafx-in-30-minutes.html"><rss:title>Getting started with JavaFX (in 30 minutes)</rss:title><rss:link>http://www.glennbech.com/home/2009/6/27/getting-started-with-javafx-in-30-minutes.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2009-06-27T13:23:20Z</dc:date><dc:subject>clas</dc:subject><content:encoded><![CDATA[<h3>After hearing a lot of buzz about JavaFX, (and the upcoming "designer tool" demoed at Java One, scheduled for Q3/Q4), I decided to get my hands dirty with JavaFX. This is not a tutorial on JavaFX but rather references, and a summary of the experience of getting started.</h3>
<p>&nbsp;</p>
<p><strong></strong>&nbsp;<strong>What is JavaFX?<br /></strong>According to the "all knowing Wikipedia"; "JavaFX is a software platform for creating and delivering rich Internet applications that can run across wide variety of connected devices. The current release (JavaFX 1.2, June 2009) enables building applications for desktop, browser and mobile phones. TV set-top boxes, gaming consoles, Blu-ray players and other platforms are planned."<br />JavaFX is not an API for GUI development, but rather a platform that uses a declarative programming language called JavaFX Script.<br />To have a quick view of the possibilities, take a look at the samples on javafx.com</p>
<p><strong></strong></p>
<p><strong>Getting started with Eclipse<br /></strong>Sun has a "getting started" tutorial that looks okay over at javafx.com. It's worth noticing that there s no mention of how to get started with Eclipse (of course). I've heard a lot of praise of Netbeans lately, but learning something new, and a new IDE at the same time is not what I wanted.<br />I started my adventure and downloaded the 45 MB JavaFX SDK, at the same time updating my Eclipse 3.5 with a JavaFX Feature. This feature will among other things enable you to create a new "JavaFX Project from the "new Project" menu. <br /><strong><br />... A Small problem, my bad<br /></strong>A minor setback occurred during my first attempt to create a JavaFX project from the "new project" menu. I got the error message;&rdquo;The JavaFX SDK location was not specified". This is because I am impatient, and installed the JavaFX plug-in before the JavaFX SDK. If this happens, it's just a matter of selecting the window/preferences dialog and select "class path variables" under "build path". There should be a JAVAFX_HOME class path variable pointing to the directory where the JavaFX SDK was installed.</p>
<p><strong></strong></p>
<p><strong>And the first project<br /></strong>Creating a JavaFX project is easy. Just select create new project from the menu, and select "JavaFX Project". After that you can create new Java FX scripts, either empty, or have some example "hello world" like scripts to start playing with.</p>
<p><strong>Conclusion<br /></strong>I was happy to see that JavaFX works with the latest eclipse. The only hiccup was a fault of my own. It's very easy to get started with JavaFX development, probably easier with Netbeans, as you can download both the IDE and SDK as a bundle. I was definitely up and running with the platform in under 30 minutes.</p>
<p>&nbsp;<strong>References</strong></p>
<ul>
<li>Wikipedia <a href="http://en.wikipedia.org/wiki/Javafx">http://en.wikipedia.org/wiki/Javafx</a></li>
<li>Sun's getting started page&nbsp; <a href="http://javafx.com/docs/gettingstarted/javafx/">http://javafx.com/docs/gettingstarted/javafx/</a></li>
<li>JavaFX SDK download page&nbsp; <a href="http://java.sun.com/javafx/downloads/">http://java.sun.com/javafx/downloads/</a></li>
<li>JavaFX Plugin for Eclipse&nbsp; <a class="ulink" href="http://javafx.com/downloads/eclipse-plugin" target="_top">http://javafx.com/downloads/eclipse-plugin</a></li>
<li>Samples and example apps&nbsp; <a href="http://www.javafx.com/samples/">http://www.javafx.com/samples/</a></li>
</ul>

Learing something new? I often find it very rewarding to have a book at my desk when trying out new stuff. Surfing around the web for good tutorials can be quite time consuming, why not check this book out and save some time?
<p>
<div>
<iframe src="http://rcm-uk.amazon.co.uk/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=FF0000&t=glebec-21&o=2&p=8&l=as1&m=amazon&f=ifr&asins=013701287X" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</div>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2009/5/30/httponly-cookies-in-the-servlet-30-specification.html"><rss:title>HttpOnly cookies in the Servlet 3.0 Specification</rss:title><rss:link>http://www.glennbech.com/home/2009/5/30/httponly-cookies-in-the-servlet-30-specification.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2009-05-30T08:11:31Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>If a web application is voulnerable to XSS attacks, your cookies can easily get in the wrong hands. One of the more popular targets for XSS attracks is of course your session cookie. In wrong hands this &nbsp;cookie can enable an attacker to impersonate you, get access to persoal information or even your bank account.</p>
<p>Back in &nbsp;2002 Microsoft implemented a mechanism called "HttpOnly Cookies" in their Internet Explorer 6 SP1". There is no magic involved; just an extra flag in the Set-Cookie response header. If the browser implements this, an attempt to read the cookie from a client side script will return an empty string.</p>
<p>Nowdays most servers and clients protects the session cookie this way; even though Ajax and the XMLHttpRequest object is lurking in the shadows. A snake in paradise but also a different story!</p>
<p>A new thing in the upcoming Servlet 3.0 specification is the support for HttpOnly custom cookies.</p>
<p>The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.Cookie) <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html#addCookie%28javax.servlet.http.Cookie%29"></a> method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.</p>
<p>In the new servlet specfication, the Cookie class has the following methods;</p>
<p>void setHttpOnly(boolean isHttpOnly)<br />boolean isHttpOnly()</p>
<p>Great news for security aware web developers!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2007/3/13/about-eclipse-and-tekken.html"><rss:title>About Eclipse and Tekken</rss:title><rss:link>http://www.glennbech.com/home/2007/3/13/about-eclipse-and-tekken.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2007-03-13T14:23:00Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p><strong>Eclipse and Tekken</strong></p><p>The keyboard shortcuts in eclipse are a bit like advanced Tekken combat moves, for those who aren't into computer games; Tekken is a very good fighting game for the Sony Play Station consoles. A lot of the cool moves can only be made using insane combinations of the controller buttons, in the right sequence. In that sense, Eclipse and the computer game has a lot in common.</p><p>So... I'm using Eclipse for the moment, and have after a long period of swearing started to adapt a way of working that is similar to what I'm used to with IntelliJ. Here are a few painkillers for other Eclipse users that are used to IntelliJ. I guess most of this will be "old news" to experienced Eclipse users, but who knows. Why might pick up a trick or two.</p><p>Before starting I have to say that I try to learn keyboard shortcuts for everything I do. Other people prefer clicking around in the interface and I respect that. However, working with mostly the keyboard has some advantages; It's faster, It's better for your health and it's faster (did I mention that?)</p><p>Even after a months of using Eclipse, I still get confused on what shortcuts that are available through CTRL+SHIFT and what is through ALT+SHIFT. A good way to remember what is what is to think of the alt+shift shortcuts as "menu shortcuts". To Illustrate; Pressing Alt+shift+s gives you about the same options as pressing "source" on the menu. The CTRL+SHIFT shortcurs are more often helper dialogues like Open resource (CTRL+SHIFT+R) or open type. (CTRL+SHIFT+T)</p><p>Anyhow; here's a compilation of my most used keyboard shortcuts for eclipse. If you use these in combination, you can probably put the mouse away entirely.</p><p><strong>Ctrl+M (Maximise) </strong></p><p>I try to do as much work as possible with the source code window maximised. I try to use the "Navigator", and "Package Explorer" windows as little as possible, as I have found no way to switch to them with focus, without using the mouse.</p><p><strong>Ctrl+F7 (Switch views)<br/></strong><br/>In IntelliJ U can easily hide and show windows like the project navigator using the ALT key and number in combination, when you want the window to go away, you can press the same key, or escape.</p><p>Using the Ctrl+F7 and Ctrl+M (see previous) in combination makes navigating the different windows a bit easier. This shortcut lets you switch between the editor, navigator, console and all other views. I use it a lot to quickly go to the editor and almost always follow up with a CTRL+M, to use the entire screen area for code editing.</p><p><strong>Ctrl + . (Next problem)<br/></strong><br/>This navigates you to the next "problem" (red or yellow marker in the sidebar).</p><p><strong>Ctrl+Shift+T (Find Type)<br/></strong><br/>Finding a class in the package explorer or navigator can be like finding the famous needle in the haystack. It is often faster to hit this combo, and start typing the name of your class.</p><p>The good news is that wildcards and camel-back searching works like a dream.</p><p><strong>Ctrl+Shift+R (Find Resource)<br/></strong><br/>Same as above, only for resources that is not java classes. (JSP files ,properties etc. )</p><p><strong>Alt+Shift+T (Refactor)<br/></strong><br/>This shortcut is pretty neat as it pops up all refactoring options, given the context of the cursor position. The action you want to take is available in only one more keystroke. In full "Tekken* style" the shortcut key for "rename" is the key 'n', instead of using for example 'r' (that is unused). Don't ask me why.</p><p><strong>Ctrl+F6 (Open files) </strong></p><p>This is probably my single most used Eclipse shortcut. It pops up a list of all the recent files you have edited. An annoying "feature" of this key is that the CTRL key has to be pressed while doing a selection, or at least for a period of time for the window to "stick". If you briefly press Ctrl+F6, you get your last window. The design idea is probably that you often swap between the two most recent files.</p><p>I always use the combo "alt+right/left key" for that, so for me this extra "intelligence" is just annoying.</p><p><strong>Alt+Right and left Arrows<br/></strong><br/>The alt key in combination with the left and right arrow keys can be used as a "back" and "forward" in the file history.</p><p><strong>F3 (Go to declaration) and "Ctrl clicking"<br/></strong><br/>The entire source code can be navigated as a hyperlinked system. If the cursor is over a class name and you press F3, you immediately go to the declaration of that class.. Pressing F3 while the cursor is over a variable takes you to the declaration of that variable.</p><p>Similar navigation can be done by holding down the ctrl key and moving the mouse around. When the mouse pointer is hovering over a class name or variable, the name of the class or variable turns into a clickable hyperlink.</p><p>other usefull shortcuts that you're probably used to from IntelliJ</p><p><strong>Ctrl+Shift+O (Optimize Imports)<br/></strong><br/>This is one of many features that IntelliJ has implemented a bit smoother than Eclipse.</p><p>In general, the "Auto import" feature doesn't work to well if your code has compilation errors. This can be impractical if you let's for example say you want to copy / paste a block into your code from somewhere, and get a lot of "red markers" in your code as a result of the unknown classes.</p><p>In Eclipse you should avoid typing entire class names, it's better to type half way through and ctri+space to auto complete. This is because it imples an automatic import.</p><p><strong>Ctrl+Shift+F (Format code)<br/></strong><br/>This key combo formats your code according to default of project specific format.</p><p><strong>Alt+Shift+X, T (Run as unit test)<br/></strong><br/>This is one of many Tekken moves in Eclipse. Press Alt+shift+X after a while, a hint-box should appear with your choices. Press T to run the current class as a unit test . A disadvantage of using this shortcut is that the class currently in the editor has to be the unit test. This shortcut is best used in combination with the CTRL+F11 shortcut explained later.</p><p><strong>Ctrl+F11 (Run last launch config)<br/></strong><br/>If you run your unit test once using alt+shift+X (something that can and will break your fingers over time) there is no need to press the same combo again. Just use Ctrl+F11 to re-execute your last "run" or "debug" configuration.</p><p><strong>Alt+Shift+Z<br/></strong><br/>The nifty surround with functionality, also the home of the automatic collection iterator shortcut.</p><p><strong>Alt+Shift+S (source)<br/></strong><br/>Here you'll find shortcuts to all the nifty things like implement/override methods, generate getters/setters etc.</p><p><strong>Ctrl+F8<br/></strong><br/>Working with perspectives is important in eclipse. The whole editor changes it's window layout when working in debug mode. The Ctri+F8 shortcut enables you to switch back to java view (where I usually work) after a debugging session.</p><p><strong>Ctrl + T<br/></strong><br/>View Implementation/type hierarchy. If your editor is showing an interface, and you want to know all available implementations, this shortcut is handy. It also works if your cursor is located over an interface declaration.</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2006/11/6/working-with-jsf-myfaces-javalangillegalstateexception-clien.html"><rss:title>Working with JSF &amp; MyFaces ; java.lang.IllegalStateException: Client-id : xxx is duplicated in the faces tree.</rss:title><rss:link>http://www.glennbech.com/home/2006/11/6/working-with-jsf-myfaces-javalangillegalstateexception-clien.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2006-11-06T11:48:00Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>If you're working with JSF using Myfaces nad Tomahawk, and you are getting a stacktrace like this, you have probably just changed the internal structure of your JSP page. For some strange reason, that doesn't work too well in all cases. </p><p>What you need to do, is to make sure a new browser session is started, and access the page again.</p><p>java.lang.IllegalStateException: Client-id : xxx is duplicated in the faces tree. Component : _idJsp0:minus, path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /cars/default/jsp/agreement/bets/doors/viewd........</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2006/10/19/poke-532810.html"><rss:title>Poke 53281,0</rss:title><rss:link>http://www.glennbech.com/home/2006/10/19/poke-532810.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2006-10-19T21:10:00Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>I recently heard the "Last ninja 2" soundtrack in a breakfast show on a Norwegian radio show. One thing lead to the other, And before I knew anyting of it I had a c64 emulator installed. To my great amusement, my fingers just automaticly typed in the command poke 53281,0 and poke 53280,0.....</p><p>Honour and respect to those who can reply with the result of theese commands on a C64 system .) </p><p>... And If this  blog entry doesn't make any sense at all to you you're just not old enough :-)</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2006/8/7/more-on-the-bea-81-servlet-filter-requestdispatcher-issue.html"><rss:title>More on the BEA 8.1 Servlet Filter &amp; RequestDispatcher issue</rss:title><rss:link>http://www.glennbech.com/home/2006/8/7/more-on-the-bea-81-servlet-filter-requestdispatcher-issue.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2006-08-07T07:17:00Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>After doing some more research, it seems that the BEA developers found the Servlet 2.3 specification to be "ambigous", and decided to create an implementation that executes filters on both incoming http requests from cleients, and on request dispatcher requests.</p><p>This issue is resolved in the Servlet 2.4 spec. and there is a "dispatcher" element in the "filter" tag in web.xml</p><p>The valid values are:</p><p>- REQUEST: (default) only when the request comes directly from the client<br/>- FORWARD<br/>- INCLUDE</p><p>Please notice that the default behaviour has changed. Upgrading to Weblogic 9.2 or or doing a manual check in the filter for repeated requests solves the problem.</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.glennbech.com/home/2006/8/3/the-bea-81-servlet-container-implementation-is-causing-probl.html"><rss:title>The BEA 8.1 Servlet Container implementation is causing problems for Jakarta Struts applications using filters.</rss:title><rss:link>http://www.glennbech.com/home/2006/8/3/the-bea-81-servlet-container-implementation-is-causing-probl.html</rss:link><dc:creator>Glenn Bech</dc:creator><dc:date>2006-08-03T09:00:00Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>I just discovered some strange behavior in a struts based application that uses Hibernate, and a mechanism based on Thread local variables to hold Hibernate Sessions.</p><p>Servlet filters are a great tool to handle aspects of your web application like custom Authorization & Authentication logging, modification of requests etc. The servlet 2.3 specs say the following in Section 6.2.1</p><p>"When the container receives an incoming request, it takes the first filter instance in the list and calls its doFilter method, passing in the ServletRequest and ServletResponse, and a reference to the FilterChain object it will use. "</p><p>The BEA developers have obviously interpreted this to mean incoming request from clients, i.e. "regular" http requests, and requests coming in via the RequestDispatcher class. The Oracle OC4J does not execute the filter chain for incoming RequestDispatcher calls. This is where it gets interesting for Struts based applications.</p><p>There are two types of "forwards" in struts, those with redirect="true", and redirect="false". When the redirect attribute of the forward tag in struts-config.xml is set to "true", a response is sent to the client, forcing it to send a new request to the server.</p><p>The actual HTTP Response going to the web browser may look something like this ;</p><p><span style="font-style: italic;">HTTP/1.x 302 Moved Temporarily<br/>Date: Thu, 03 Aug 2006 08:37:07 GMT<br/>Server: Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)<br/>Content-Length: 222<br/>Connection: Keep-Alive<br/>Keep-Alive: timeout=15, max=100<br/>Content-Type: text/html<br/>Location: http://localhost:9999/adminssytem/viewEmployees.do</span></p><p>In this case, the filter chain should- and is, executed twice per client transaction. The user does not notice both requests though. This practice is quite common when using the HTTP Post method, so that the user can "reload" the page in his browser without re-posting the form data.</p><p>The forwards with redirect="false", uses a RequestDispatcher to forward requests internally. This is sometimes also called "Server Side redirect", and is very useful since you can chain struts actions together in a "Chain of responsibility pattern". By creating small reusable actions, you can easily use them as building blocks in your application.</p><p>The fact that BEA chooses to execute the filter chain, between struts actions has a huge impact on code relying on this mechanism. Taking the example of Authorization, a costly verification of user credentials will be executed between each Struts action. With long action chains, this can be a huge performance penalty.</p><p>In this Example;</p><p>&lt;action path=&quot;/deletePhoneNumber&quot;</p><p>type=&quot;DeletePhoneNumberAction&quot; </p><p>name=&quot;PhoneForm&quot;</p><p>scope=&quot;request&quot;&gt; </p><p>  &lt;forward name=&quot;success&quot; path=&quot;/viewPhoneNumbers.do&quot;/&gt;</p><p>&lt;/action&gt; </p><br/><p>&lt;action path=&quot;/viewPhoneNumbers&quot;<br/> <br/>type=&quot;ViewPhoneNumbersAction&quot;<br/> <br/>name=&quot;PhoneForm&quot;<br/> <br/>scope=&quot;request&quot;&gt; </p><p>&lt;forward name=&quot;success&quot; path=&quot;/WEB-INF/jsp/displayNumbers.jsp&quot;/&gt;</p><p>&lt;/action&gt;</p><p>A filter with a .do mapping, will be executed two times in the Weblogic server.</p><p>1) On the initial HTTP Request hits the deletePhoneNumberAction.<br/>2) After the DeletePhoneNumberAction is finished, and before the viewPhoneNumbers Action is executed.</p><p>This can impact design, cause bugs, and slow down the system significantly. If anyone has a workaround, or know of an entry in the weblogic.xml that solves this, please feel free to comment. It would also be interesting to know the rationale behind the decision to implement the Servlet container with a very “creative” interpretation of the specification in this case.</p>]]></content:encoded></rss:item></rdf:RDF>