Short Tech HOW-TOs

Define datasource in Tomcat

create context.xml with following content in your webapp/META-INF

<Context docBase="/MY_DATASRC privileged="true" antiResourceLocking="false" antiJARLocking="false">

<!-- HSQL DB -->
<!--
    <Resource name="jdbc/
MY_DATASRC" auth="Container"
                    type="javax.sql.DataSource" driverClassName="org.hsqldb.jdbcDriver"
                    url="jdbc:hsqldb:hsql://localhost/xdb"
                    username="sa" password="" maxActive="20" maxIdle="10"
              maxWait="-1"/>
 --> 
<!-- Oracle -->
    <Resource name="jdbc/
MY_DATASRC" auth="Container"
                    type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
                    url="jdbc:oracle:thin:@HOST:PORT:INSTANCE"
                    username="UID" password="PWD" maxActive="20" maxIdle="10"
              maxWait="-1"/>
</Context>

Useful shell commands
 Strip .svn info  find . -name .svn -type d -print0 | xargs -0 rm -rf
Change directory permissions recursively  find /home/domains/*/ -type d -exec chmod 777 {} \;
 Add system user
 sudo adduser --system --home / --no-create-home --ingroup <group> --disabled-login --disabled-password <user_name>
 Run command under different user
 sudo su -m <user> -c "command"
On linux download file located on windows
smbget -w DOMAIN -u user -p password smb://host/share/folder/file.ext


Public key authentication with ssh
  • Create private and public keys: ssh-keygen -t dsa
            Accept default key location and optionally enter passphrase
  • Copy the public key  to the server cat ~/.ssh/id_dsa.pub | ssh user@server "cat - >> ~/.ssh/authorized_keys"

JSTL 1.2 Expressions

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="your-webapp-id" version="2.5">

JSP <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:form="http://www.springframework.org/tags/form" xmlns:spring="http://www.springframework.org/tags"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
<jsp:directive.page contentType="text/html" />

<html>
...
</html>
</jsp:root>

Groovy shebang
#!/usr/bin/env groovy

Convert Maven webapp to support Eclipse
mvn eclipse:eclipse -Dwtpversion=2.0
review  org.eclipse.wst.common.project.facet.core.xml 

SmartGWT with Eclipse Google Plugin

  1. Create Web Application Project
  2. Add smartgwt.jar and smartgwt-skins.jar to the project
  3. Remove "inherits" reference to com.google.gwt.user.theme.standard.Standard from project gwt.xml
  4. Add "inherits" reference to com.smartgwt.SmartGwt and com.smartclient.theme.silverwave.SilverWave
  5. In project html file add following before main proj.nocache.js
    • <script> var isomorficDir = "<proj>/sc/"; </script>