java jre

HowTo: Enable URL rewite for tomcat or other servlet container

Posted on Updated on

It is a URL rewrite feature which is most similar to the apache mod_rewrite, we can use the similar rules to apply the rewrite. Ensure that the ‘UrlRewriteFilter‘ JAR file is on your web-application’s classpath.  place the JAR file in your webapp under ‘/WEB-INF/lib’ will do the trick, and if you’ve spent any time at all working with webapps you probably already have a preferred way of doing this. Alternately, you may want to install the JAR file in your servlet container’s ‘/lib’ folder, particularly if you are deploying multiple webapps on your server and you want to have ‘UrlRewriteFilter‘ available to any/all of them automatically.

Download JAR from here

Read more Examples

once you have the ‘UrlRewriteFilter‘ JAR on your webapp’s classpath, the real setup can begin. Open your application’s ‘web.xml‘ file, and add the following filter configuration to your webapp

<filter>
 <filter-name>UrlRewriteFilter</filter-name>
 <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
 <init-param>
 <param-name>logLevel</param-name>
 <param-value>WARN</param-value>
 </init-param>
<init-param>
 <param-name>confPath</param-name>
 <param-value>/WEB-INF/urlrewrite.xml</param-value>
 </init-param>
</filter>
 <filter-mapping>
 <filter-name>UrlRewriteFilter</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>

This will make the serverlet container to redirect the traffic to UrlRewriteFilter.  Note that although it is not discussed on the official site, that ‘logLevel‘ parameter is absolutely essential for filter to be apply for the traffic.

If you finish adding the tags in web.xml, then move to create urlrewrite.xml in the same directory as with the web.xml. Configure the example rules  for  the URL rewrite.

<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
 "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
 <urlrewrite>
  <rule>
        <name>Domain Name Check</name>
        <condition name="host" operator="notequal">www.server.com</condition>
        <from>^(.*)$</from>
        <to type="redirect">http://www.server.com/$1</to>
    </rule>
    <rule>
        <from>/test</from>
        <to type="redirect">%{context-path}/examples</to>
    </rule>
</urlrewrite>

The first rule is for any request tot he application with IP or alternative alias Domain name added in the server has to rewrite to server.com. It can be also use to rewite for including www. in the URL .

The second rule is for the redirect the invalid application “test” to  to the examples,

Its looks like this :  http://test.com/test   –>  http://www.server.com/examples/  . Both the test.com and server.com are in the same server and same webapps

 

 

Advertisements

info: How to install java on Ubuntu.

Posted on Updated on

JAVAJava is a object-oriented computer programming language developed by James Gosling  at Sun Microsystems and released in 1995 lated it has been migrated to

Oracle systems. The code that can runs on one platform does not need to be recompiled.

Ubuntu

Install oracle java 7 in ubuntu 12.04
Here I have described about one of the easiest installation method of Oracle-JAVA on Ubuntu using JAVA repository. for more information : http://en.wikipedia.org/wiki/Java_(programming_language)

Open the terminal and run the following commands

# java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK Server VM (build 20.0-b12, mixed mode)

# sudo add-apt-repository ppa:webupd8team/java
# sudo apt-get update
# sudo apt-get install oracle-java7-installer

Now check the new updated verison

# java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Server VM (build 23.21-b01, mixed mode)

 

sdf

Check the installation directory:

anand@desktop:~$ ll /usr/lib/jvm/java-7-oracle/
total 19720
drwxr-xr-x 8 root root 4096 May 3 09:32 .
drwxr-xr-x 6 root root 4096 May 3 09:32 ..
drwxr-xr-x 2 root root 4096 May 3 09:32 bin
-r--r--r-- 1 root root 3339 May 3 09:32 COPYRIGHT
drwxr-xr-x 4 root root 4096 May 3 09:32 db
drwxr-xr-x 3 root root 4096 May 3 09:32 include
drwxr-xr-x 5 root root 4096 May 3 09:32 jre
drwxr-xr-x 3 root root 4096 May 3 09:32 lib
-r--r--r-- 1 root root 40 May 3 09:32 LICENSE
drwxr-xr-x 4 root root 4096 May 3 09:32 man
-r--r--r-- 1 root root 114 May 3 09:32 README.html
-rw-r--r-- 1 root root 443 May 3 09:32 release
-rw-r--r-- 1 root root 19838528 May 3 09:32 src.zip
-rw-r--r-- 1 root root 123324 May 3 09:32 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r-- 1 root root 172252 May 3 09:32 THIRDPARTYLICENSEREADME.txt

 

That’s all 🙂

Howto: Installing,Upgrading JAVA on Centos,Fedora,Ubuntu,RHEL5

Posted on

Download JAVA and follow the below installtion steps.

Use Java JDK absolute version (/usr/java/jdk1.7.0_03)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 20000


Use Java JRE latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000

## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 20000

 

 

Check current java, javac, javaws and libjavaplugin.so versions

 

java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

javaws
Java(TM) Web Start 10.0.0.4-fcs
[...]

javac -version
javac 1.7.0_03


Swap between OpenJDK and Sun/Oracle Java JDK/JRE 6 and 7 versions

JAVA

alternatives --config java

There are 5 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/java/jdk1.6.0_26/jre/bin/java
   4           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   5           /usr/java/jdk1.7.0_03/jre/bin/java

Enter to keep the current selection[+], or type selection number: 5

Note: java with [+] is currently on use

javaws

alternatives --config javaws

There are 3 programs which provide 'javaws'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/javaws
 + 2           /usr/java/jdk1.6.0_26/jre/bin/javaws
   3           /usr/java/jdk1.7.0_03/jre/bin/javaws

Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use

libjavaplugin.so (32-bit)

alternatives --config libjavaplugin.so

There are 3 programs which provide 'libjavaplugin.so'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/i386/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/i386/libnpjp2.so
   3           /usr/java/jdk1.7.0_03/jre/lib/i386/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3.

javac

alternatives --config javac

There are 3 programs which provide 'javac'.

  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/bin/javac
 + 2           /usr/java/jdk1.6.0_26/bin/javac
   3           /usr/java/jdk1.7.0_03/bin/javac

Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use


Post-Installation Setup

Add JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file

Java JDK and JRE latest version (/usr/java/latest)

## export JAVA_HOME JDK/JRE ##
export JAVA_HOME="/usr/java/latest"

Java JDK and JRE absolute version (/usr/java/jdk1.7.0_03)

## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.7.0_03"

## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.7.0_03"