Tuesday, 18 September 2012

wget HEAD request?

I wanted  to send HTTP HEAD request using wget, is it possible I wondered?

No as it's not wget, but you can do that quite easily by using curl.
curl -I http://www.superuser.com/
Produces this output:
HTTP/1.1 301 Moved Permanently                        
Content-Length: 144                       
Content-Type: text/html; charset=UTF-8     
Location: http://superuser.com/
Date: Sat, 09 Oct 2010 19:11:50 GMT
 
Thanks superuser.com!

Download Java JRE/JDK 7 from shell

File under the heading of Arrgh @#@?#&!

While setting up Tomcat7 from a console window on CENTOS I thought I would download the JDK but you can't because the fhe first step to do so, is to wget (download) the rpm / bin install file?

But as a fellar called Shmuel points out "Well it seems like since Java7, you must accept license agreement on the download page, before you can download java, which make sense. The problem with that is that you cannot accept this license agreement if you are on shell, doing wget."

In summary:
  1. Use Firefox & enable Fiddler to spy on your browser history;
  2. Go and find the down load you need from here;
  3. Accept the licence conditions and start the down;
  4. Then copy from fiddler the URL and most importantly the authorisation parameter which you can just add to your wget url.

Saturday, 8 September 2012

Set up Remote Debugging in Tomcat

Debugging tomcat can be a little but of a pain especially when it is a remote server.
So a quick solution is to use a remote debug option.
A good article on this can be found here (http://en.newinstance.it/2005/10/04/remote-debugging-tomcat-with-eclipse/).
But to add to this information I created a batch file called "runDebug.bat" in the tomcat/bin folder.

The file is:

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
catalina jpda start

Adding process monitoring

Having set that up you may want to use JConsole to monitor the process.
JConsole comes with the JDK and can be found lurking in the bin folder of your Java installation. 

To enable it with Tomcat you need to mmend your batch file as follows:

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
set JXM_PORT=5636
set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=%JXM_PORT% -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.hostname=%COMPUTERNAME%/%JXM_PORT%

(NB. Make sure the CATALINA_OPTS is on one line).

A usefull reference on JConsole can be found here (http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html)
 
The next thing you will want to do is add some MBeans to your project. Which can be handled via Annotations.