Accessing web application resources from different context

You can access the resources which are available for one servlet context from the other. Let’s say you have two web applications deployed (in the same Servlet container): /myApp1 /myApp2 Basically, if you’re in /myApp1 and you will execute the getServletContext() method on ServletRequest object, it will return the ServletContext for the application related with this ServletRequest object (in this case – /myApp1). With the ServletContext object you can execute getResource(-) or getResourceAsStream(-) to get access to the needed resource from within the /myapp1 application....

January 27, 2011 · 2 min

Eclipse PDT and gray file comparison window

Today I’ve bumped into some weird problem with PHP files comparison using Eclipse PDT and Subclipse (SVN). When a file was selected and “Compare with… Latest from Repository” option was chosen, the comparison window become gray, no code source was displayed and no error message was shown. It was just the same if you tried to compare a file with your local history or two separate files with each other....

January 17, 2011 · 1 min

Every possible combination of given letters in BASH

If you want to create every possible word or combination of letters (or any other characters) you can use very simple BASH function: $ echo {a..c} This command will print all possible letters starting with a and ending on c (inclusive), so the result is: a b c You can get every possible combination of letters from the given range, which length is larger than 1, i.e.: $ echo {a..c}{a..c} This command will print every possible combination of letters starting with a and ending on c (inclusive) with another letter from the same range....

January 15, 2011 · 1 min

MD5 checksum in PHP and BASH

I wondered why the same word has different MD5 checksum if I use the PHP md5(-) method and BASH md5sum command. What I mean is: <?php echo md5("sol"); ?> The result is: 12313a3d28f802e3a22b07d2e01c6dcf $ echo "sol"|md5sum The result is: 56717d999058f0e053d4b580c9396a92 It’s so because the echo command – by default – adds a newline character after its execution, so it really creates a MD5 checksum of: ‘sol\n’. To avoid it, you can use the -n echo switch which disables the trailing newline character for this command....

January 15, 2011 · 1 min

JavaBeans -- getters with Boolean type

When you want to create a boolean property in a Java Bean (let’s name it visible), you most likely would want to use a boolean type variable and create accessors for it. Well, if you use a boolean primitive it is allowed to create a getter in one of two manners: public boolean getVisible() or public boolean isVisible() Notice that the second option is only allowed when your property is a boolean primitive....

January 13, 2011 · 1 min

Automatically build number generation in ANT

I wanted to find some solution to a problem of automatic generation of build numbers/version identifiers using an ANT. I figured out that I can achieve it in the following way: <target name="numerate.version" description="Generates version number and sets it in Client properties file."> <tstamp> <format property="build.time" pattern="yy-MM-dd_hh:mm" unit="hour" /> </tstamp> <buildnumber file="build.number" /> <property name="version.code" value="${build.version}/${build.time}/${build.number}" /> <echo>Version: ${version.code}</echo> <replaceregexp file="${client.commonsi18n.pl}" match="(version[ \t]*=[ \t]*)+.*$" byline="true" replace="\1${version.code}" /> </target> A short description what is going on:...

January 9, 2011 · 1 min

Axis and Java2WSDL

In the Axis2 (which you can download from this site) bin subdirectory, there is a java2wsdl.sh file which can be used to generate a WSDL file from plain Java classes. Below is a very rough example how to use it: /home/palli/axis2-1.5.4/bin/java2wsdl.sh -o /home/palli/ -of Test.wsdl -sn WSAdditionalOperations -cp . -cn com.nullhaus.ediploma.server.WSAdditionalOperations Used arguments: Parameter Description o output directory where the generated WSDL will be saved of output filename of the WSDL cp java classpath sn name of the service cn fully qualified name of the class you want to be used to generate the WSDL file

January 8, 2011 · 1 min

Problem with execution of SNX on GNU/Linux (libstdc++)

I’ve recently bumped into a problem with using a SSL Network Extender when trying to establish a VPN connection through the web browser. The SNX was throwing a ‘failed to initialize’ error without any details despite the right credentials. To identify the error, I needed to execute the snx from the command line (snx) which points that the SNX is missing a libstdc++.so.5. I had a libstdc++.so.6 installed at that point....

January 4, 2011 · 1 min

JAR from command line -- the arguments order does matter

When you create a *.jar file using jar command-line tool, it is worth to remember that the order of arguments does matter, so: jar cmvf projects/myTags/etc/MANIFEST.MF myTags.war myTags means that you must firstly provide the manifest file (m), than the JAR filename (f). If you use the same order of arguments but change the switches like this: jar cvfm projects/myTags/etc/MANIFEST.MF myTags.war myTags the command will not be executed. According to the switches, your first argument should be the JAR filename (f) and then manifest file (m)....

January 2, 2011 · 1 min

System-wide SOCKS Proxy

Sometimes, there is a need to use SOCKS Proxy for connection even if an application itself isn’t providing such feature. If you’re working on Windows you can use FreeCap which allows you to put your applications into FreeCap “sandbox”. Every time you run app from this “sandbox” it is sent through the SOCKS proxy you set as an configuration option. Update: Recently I’ve heard that it is somewhat impossible to execute this application on Windows 7....

December 23, 2010 · 1 min