<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#187; Java</title>
	<atom:link href="http://blog.marcuscobden.co.uk/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.marcuscobden.co.uk</link>
	<description>Reflections of a compulsive engineer</description>
	<lastBuildDate>Wed, 01 Sep 2010 10:05:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>On-demand TCP over DNS server</title>
		<link>http://blog.marcuscobden.co.uk/2010/08/on-demand-tcp-over-dns-server/</link>
		<comments>http://blog.marcuscobden.co.uk/2010/08/on-demand-tcp-over-dns-server/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 13:24:39 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://blog.marcuscobden.co.uk/?p=40</guid>
		<description><![CDATA[Virtual servers have become quite cheap these days, to the point where I can justify paying the monthly charge on one when I&#8217;m not sure how much I&#8217;ll use it. One of the things I have been running on my VM is a TCP-over-DNS server; it will allow you access to the Internet through some [...]]]></description>
			<content:encoded><![CDATA[<p>Virtual servers have become quite cheap these days, to the point where I can justify paying the monthly charge on one when I&#8217;m not sure how much I&#8217;ll use it.</p>
<p>One of the things I have been running on my <abbr title="Virtual Machine">VM</abbr> is a <a href="http://analogbit.com/software/tcp-over-dns">TCP-over-DNS server</a>; it will allow you access to the Internet through some access points where you&#8217;re forced to login, though it relies on the network administrator neglecting to block certain types of DNS query.  The author has posted a good <a href="http://analogbit.com/tcp-over-dns_howto">how-to and overview</a> of how it works so I&#8217;m not going to go into that here.</p>
<p>Now, I don&#8217;t anticipate using this tunneller very often so it&#8217;d be nice to not run the daemon all the time, but I obviously can&#8217;t enable myself unless I know in advance that I won&#8217;t have Internet access. Therefore, ideally I want the server to run only when I want to use it. Fortunately Linux has long had a means of doing this with the inetd daemon.</p>
<p>The inetd daemon will monitor a network socket, waiting for incoming traffic, and launch your daemon only when it is needed. It then passes the daemon process the existing sockets and waits for it to finish, at which point it&#8217;ll go back to watching for traffic again.</p>
<p>The config line you&#8217;ll need for inetd is as follows (you may need to highlight it and copy it elsewhere, as it doesn&#8217;t show up well in this theme):</p>
<pre>domain  dgram   udp     wait    root    /usr/bin/java   java -jar /path/to/tcp-over-dns-server.jar --domain delegated.domain.com --forward-port 22 --forward-address 127.0.0.1 --mtu 1500 --log-level 1 --idle-timeout 10 --log-file /var/log/tcp-over-dns</pre>
<p>Aside from modifying the server to support inherited channels I have:</p>
<ol>
<li>Added an idle time limit (so the program can exit if it sees no clients after a set number of seconds, and let inetd monitor the port again)</li>
<li>Added a log file option (programs launched by inetd can&#8217;t log to the standard output or error channels as inetd will pipe them into the inherited connection.)</li>
<li>Changed the default behaviour (If a channel is inherited the server will no longer try to bind on its default port)</li>
</ol>
<p>If you&#8217;re interested you can download <a href="http://blog.marcuscobden.co.uk/wp-content/uploads/2010/08/TCP-over-DNS-inetd.tgz">the source code</a> or just the <a href="http://blog.marcuscobden.co.uk/wp-content/uploads/2010/08/tcp-over-dns-server.jar">pre-compiled jar file</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.marcuscobden.co.uk/2010/08/on-demand-tcp-over-dns-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A case of bad cropping</title>
		<link>http://blog.marcuscobden.co.uk/2008/08/case-of-bad-cropping/</link>
		<comments>http://blog.marcuscobden.co.uk/2008/08/case-of-bad-cropping/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 21:41:00 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Applet]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://newblog.marcuscobden.co.uk/?p=10</guid>
		<description><![CDATA[Recently, by pure chance, I&#8217;ve been working for two different research projects which both have involved Java Applets. The first project ran afoul of bug #6669818 which prevented the applet from connecting back to the originating server during LiveConnect calls, in Mozilla Firefox on a Windows XP platform. Fortunately there is a workaround for this; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, by pure chance, I&#8217;ve been working for two different research projects which both have involved Java Applets.</p>
<p>The first project ran afoul of <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6669818">bug #6669818</a> which prevented the applet from connecting back to the originating server during <a href="http://en.wikipedia.org/wiki/LiveConnect">LiveConnect</a> calls, in Mozilla Firefox on a Windows XP platform.</p>
<p>Fortunately there is a workaround for this; by passing the task off to another thread which was started in a non-LiveConnect part of the <a href="http://java.sun.com/docs/books/tutorial/deployment/applet/lifeCycle.html" title="Applet Lifecycle">Applet&#8217;s lifecycle</a>, the task is then executed in another thread which is not subject to the same malfunctioning security check.</p>
<p>If you&#8217;d rather not have to create a thread just for this, a quick hack is to pass the event off to the applet rendering thread using the <code>SwingUtilities.invokeLater(Runnable);</code> function.</p>
<p>In the second project I&#8217;ve now encountered another platform-specific Applet quirk, this time with Mac OSX.</p>
<p>Using Javascript it is possible to change the size of an Applet on the page in the same way you would any other DOM element, however on Mac OSX any browser using the <a href="http://javaplugin.sourceforge.net/" title="Java Embedding Plugin">Java Embedding Plugin</a> (Firefox, Opera and others) will fail to resize Java Applets correctly.</p>
<p>I&#8217;ve knocked up a simple <a href="http://marcuscobden.co.uk/stuff/2008-07/applet/" title="Applet resize test page">test page</a> which allows this to be tested, and shows a potential workaround.</p>
<p>There appear to be two problems cropping up; the first is that the Browser does not notify the Applet that it ought to resize. If you leave the &#8220;Notify Java&#8221; check-box un-checked when submitting the form, the browser expands the area the Applet ought to be using, but the applet continues to draw in it&#8217;s original position.</p>
<p>The second issue is that when axis are changed and Java is <strong>manually</strong> notified the behaviour still does not perform as it ought to. The clipping region of the Java applet rendering is not updated correctly, and thus only part of the applet is correctly rendered.</p>
<p>There is a temperamental workaround for this, by programatically resizing one axis and then the other in quick succession, but this seems to fail as often as it works, depending on whether the page is being loaded from nothing, refreshed, no-cache refreshed or returned to via the browser &#8216;Back&#8217; action.</p>
<p>In the interest of getting this bug fixed the code to the <a href="http://marcuscobden.co.uk/stuff/2008-07/applet/" title="Applet resize test page">Applet resize test page</a> is linked from the test page and free for all to use.</p>
<p>Bugs:</p>
<ul>
<li>Java Embedding Plugin tracker: <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=2030298&amp;group_id=107955&amp;atid=649116">#2030298</a></li>
<li>Firefox Bugzilla: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=451882">#451882</a></li>
</ul>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.marcuscobden.co.uk/2008/08/case-of-bad-cropping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring MVC Wizards &amp; Form Taglib</title>
		<link>http://blog.marcuscobden.co.uk/2008/01/spring-mvc-wizards-form-taglib/</link>
		<comments>http://blog.marcuscobden.co.uk/2008/01/spring-mvc-wizards-form-taglib/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 16:30:00 +0000</pubDate>
		<dc:creator>Marcus</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://newblog.marcuscobden.co.uk/?p=6</guid>
		<description><![CDATA[I&#8217;ve been building a JSP based website for a course module titled &#8220;Technologies for Electronic Commerce&#8221;. It&#8217;s finished now, but I&#8217;ve only just got round to writing up this post. As part of this I was trying to make a multi-page form, using Spring&#8216;s AbstractWizardFormController and spent an hour or so trying to make the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been building a JSP based website for a course module titled &#8220;Technologies for Electronic Commerce&#8221;. It&#8217;s finished now, but I&#8217;ve only just got round to writing up this post.</p>
<p>As part of this I was trying to make a multi-page form, using <a href="http://www.springframework.org/">Spring</a>&#8216;s <a href="http://static.springframework.org/spring/docs/2.5.x/api/index.html">AbstractWizardFormController</a> and spent an hour or so trying to make the form submission change the form page. My problem was that it wasn&#8217;t immediately obvious how to use the <a href="http://static.springframework.org/spring/docs/2.0.x/reference/mvc.html#mvc-formtaglib">form taglib</a> with the Wizard architecture.</p>
<p>The docs mentioned using request parameters, which was a bit confusing as I was using a POST form submission, however all you actually need to do is add one of these parameters to the form data (usually using a button).</p>
<blockquote><p>Finish and cancel actions can be triggered by request parameters, named PARAM_FINISH (&#8220;_finish&#8221;) and PARAM_CANCEL (&#8220;_cancel&#8221;), ignoring parameter values to allow for HTML buttons. The target page for page changes can be specified by PARAM_TARGET, appending the page number to the parameter name (e.g. &#8220;_target1&#8243;). The action parameters are recognized when triggered by image buttons too (via &#8220;_finish.x&#8221;, &#8220;_abort.x&#8221;, or &#8220;_target1.x&#8221;).</p></blockquote>
<p>For example:
<pre><code>&lt;input value="Submit" name="_target1" type="submit"/&gt;</code></pre>
<p>This will request to change to page 2 of the form (remember Array base is 0).<br />
Because of the way forms work, you can have a number of these (either as clickable images or buttons) and only the one the user eventually selects will be submitted with the request.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.marcuscobden.co.uk/2008/01/spring-mvc-wizards-form-taglib/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
