Spring MVC with thymeleaf

Spring MVC application with thymeleaf

Objective: Substitue view-layer web technologies such as JSP.

Pre-req: Spring STS as development environment

Why thymeleaf?: 

  • Natural templating for easy prototyping: display your templates statically in a browser (without running your app server).
  • Complete integration with Spring MVC (SpringStandard): form binding, property editors, internationalization, etc.
  • Full (and extensible) internationalization support: easy inclusion of externalized messages into templates.
  • URL rewriting capabilities for adding context and session information to URLs.
  • Spring Security support.
  • Out-of-the-box: templates can be read as classloader or ServletContext resources, as well as files (from the filesystem) and by calling URLs.

Steps:

  1. Create spring mvc project
    • Go to File > New > Spring MVC Project
    • Select project name (ess) and top level package (com.njoshi.ess)
  2. Right click on project name > run on server to make sure project configuration is working
  3. Add thymeleaf dependancy
    • Open pom.xml
    • Add following dependancy
    • <dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf-spring3</artifactId>
      <version>2.1.3.RELEASE</version>
      </dependency>
  4.  SpringTemplateEngine
    • Configure thymeleaf template engine in ess/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
    • Edit header to
      <beans xmlns=”http://www.springframework.org/schema/beans”
      xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:context=”http://www.springframework.org/schema/context”
      xsi:schemaLocation=”http://www.springframework.org/schema/beans

      http://www.springframework.org/schema/beans/spring-beans.xsd

      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd”>

    • <bean id=”templateResolver”
      class=”org.thymeleaf.templateresolver.ServletContextTemplateResolver”>
      <property name=”prefix” value=”/WEB-INF/views/” />
      <property name=”suffix” value=”.html” />
      <property name=”templateMode” value=”HTML5″ />
      </bean><bean id=”templateEngine” class=”org.thymeleaf.spring3.SpringTemplateEngine”>
      <property name=”templateResolver” ref=”templateResolver” />
      </bean><bean class=”org.thymeleaf.spring3.view.ThymeleafViewResolver”>
      <property name=”templateEngine” ref=”templateEngine” />
      </bean>
  5. Changes in home.jsp
    • Change home.jsp to home.html
    • Change server time to <p th:text=“${serverTime}”>Welcome to time check page. Site is down!</p>

Source code: https://github.com/nnjoshi14/ess/tree/0.1

Installing Oracle 11G R2 on Cent OS 6.5 (x86-64)

Guide for Installing Oracle 11G R2 on CentOS

Pre-req: Cent OS 6.5 (x86-64)
disable selinux and iptables

Download: 11G R2 from Oracle.com

Update system control:
cat >> /etc/sysctl.conf <<EOF
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
EOF
/sbin/sysctl -p

Required packages: Install by using yum
yum install binutils-2*x86_64* glibc-2*x86_64* nss-softokn-freebl-3*x86_64* glibc-2*i686* nss-softokn-freebl-3*i686* compat-libstdc++-33*x86_64* glibc-common-2*x86_64* glibc-devel-2*x86_64* glibc-devel-2*i686* glibc-headers-2*x86_64* elfutils-libelf-0*x86_64* elfutils-libelf-devel-0*x86_64* gcc-4*x86_64* gcc-c++-4*x86_64* ksh-*x86_64* libaio-0*x86_64* libaio-devel-0*x86_64* libaio-0*i686* libaio-devel-0*i686* libgcc-4*x86_64* libgcc-4*i686* libstdc++-4*x86_64* libstdc++-4*i686* libstdc++-devel-4*x86_64* make-3.81*x86_64* numactl-devel-2*x86_64* sysstat-9*x86_64* compat-libstdc++-33*i686* compat-libcap* unixODBC-2*i* unixODBC-2* unixODBC-d*-2*i* unixODBC-d*-2*

Create oracle user and groups:
groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmadmin oracle
passwd oracle

Create oracle installation directory:
mkdir -p /u01/app/oracle
chown -R oracle:dba /u01/

Configure security limits:
cat >> /etc/security/limits.conf << EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
oracle soft stack 10240
EOF

IMP: Login as oracle user for all operations below

Configure directory path:
cat >> ~/.bash_profile << EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
EOF

Unzip 11GR2: Unzip linux.x64_11gR2_database_1of1.zip and linux.x64_11gR2_database_1of2.zip in same folder.

Start installation: ~/database/runInstaller