Notes by Dr. Xi
Displaying keyword search results 1 - 10
Created by Dr. Xi on April 19, 2012 10:10:08
Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml :
<servlet>
<servlet-name>default</servle...
Therefore, static content is rendered by the default configuration unless you override it with your own definitions.
If you want to allow directory listing, just change the listing parameter to true :
<init-param>
<param-name>listings</para...
Change the welcome-file-list to display a default page in lieu of a directory listing:
<welcome-file-list>
<welcome-file>home.xhtml</...
Welcome pages are defined at the Web application level.
Created by Dr. Xi on February 13, 2012 20:48:56
Last update: February 13, 2012 20:48:56
When you insert an attribute in JSP:
<%@ taglib uri="http://tiles.apache.org/tags-tiles...
you must define the attribute in tiles definitions:
<definition name="/home" template="/WEB-INF/templa...
Otherwise you'll get runtime exception.
The ignore attribute, which defaults to false , will suppress the runtime exception when the attribute is not defined in tiles definition:
<%@ taglib uri="http://tiles.apache.org/tags-tiles...
Created by Dr. Xi on February 01, 2012 12:55:28
Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context...
which is equivalent to the following in web.xml :
<env-entry>
<env-entry-name>varName</env-entr...
In Java code, the variable can be looked up like this:
// import javax.naming.Context;
// import javax...
Created by Dr. Xi on January 20, 2012 15:05:14
Last update: January 20, 2012 15:06:15
Tomcat documentation states:
If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/ [enginename] / [hostname] / and renamed to match the application's context path .
For a Maven project, put context.xml in src/main/webapp/META-INF/ .
Created by Dr. Xi on January 17, 2012 11:58:16
Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7:
Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib .
Add JavaMail resource to $CATALINA_BASE/conf/context.xml :
<?xml version="1.0"?>
<Context>
.
...
Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app...
Use the JavaMail resource in your webapp:
// import javax.naming.*;
// import javax.mail....
Created by Dr. Xi on September 19, 2011 11:56:42
Last update: September 19, 2011 11:57:26
It is well known that with the -D switch you can turn an ssh session into a socks proxy:
ssh -D localhost:8080 remote_user@remote_host
Now configure your browser to use " localhost:8080 " as a socks proxy and your web traffic is routed through remote_host via an ssh tunnel.
But sometimes you encounter an error message like this:
Disconnecting: Bad packet length - 1416586337
This is because sometimes, the ssh session outputs some "welcome" message into the tunnel, polluting the protocol stream between the client and the remote host.
A safer way to establish an ssh socks proxy would be:
ssh -N -D localhost:8080 remote_user@remote_host
Created by Dr. Xi on April 27, 2011 11:57:36
Last update: April 27, 2011 11:58:35
This is a sample struts-config.xml file for Struts 1.x .
<?xml version="1.0" encoding="UTF-8"?>
<!DO...
Created by Dr. Xi on April 26, 2011 21:25:55
Last update: April 27, 2011 11:08:57
The following code validates a web.xml file against the web-app 2.5 schema:
// Java XML validation with schema
import java....
web.xml used for testing:
<?xml version="1.0" encoding="UTF-8"?>
<web-ap...
According to Java API doc , validation can also be done while parsing by calling setSchema on the parsing factory. However, validation doesn't work for the SAXParserFactory!
// Java XML validation with schema
import java....
Created by Dr. Xi on April 01, 2011 12:59:10
Last update: April 04, 2011 14:14:17
To configure Tomcat HTTP Basic Authentication with SSL:
Configure web app for basic authentication (add these in web.xml ):
<security-constraint>
<web-resource-collec...
Three elements are needed for this to work: security-constraint with the url-pattern to protect, login-config for the type of authentication method to use, and security-role for the role name(s) used in the security-constraint .
Add login info to conf/tomcat-users.xml :
<tomcat-users>
<role rolename="testUserRole...
Turn on SSL in conf/server.xml :
<Connector port="8443" protocol="HTTP/1.1" SSLEnab...
For default keystore file ${user.home}/.keystore , the keystoreFile attribute can be omitted. Otherwise, add keystoreFile="/path/to/keystore/file" .
The setup is different if you are using APR .
Created by Dr. Xi on March 31, 2011 15:03:26
Last update: April 01, 2011 12:34:50
Create an openssl configuration file which enables subject alternative names ( openssl.cnf ):
[req]
distinguished_name = req_distinguished_...
Create a certificate request using above configuration file:
C:\work>openssl req -new -key testServer.key -out ...
Verify the request was created successfully:
C:\work>openssl req -text -noout -in testServer.cs...
(Optional) self-sign the certificate request:
C:\work>openssl x509 -req -days 3650 -in testServe...