Tomcat

Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.

Installation on Slackware

Start Tomcat

/opt/apache-tomcat-7.0.53/bin/ ./startup.sh http://localhost:8080/

Add admin user

Edit tomcat-users.xml

  <role rolename="admin"/>
  <role rolename="manager"/>
  <role rolename="manager-gui"/>
  <user username="admin" password="12345678" roles="admin,manager,manager-gui"/

WebApps location

A WAR file can be copied or exploded in the webapps folder.

Sample App

Download http://localhost:8080/docs/appdev/sample/sample.war and deploy in the webapps folder. After the deploy the WAR file is exploded.

Configuration values in web.xml

Adapted from http://stackoverflow.com/questions/372686/how-can-i-specify-system-properties-in-tomcat-configuration-on-startup

   1 <env-entry>
   2     <env-entry-name>SMTP_PASSWORD</env-entry-name>
   3     <env-entry-type>java.lang.String</env-entry-type>
   4     <env-entry-value>abc123ftw</env-entry-value>
   5 </env-entry>

Get values in code

   1 // Obtain our environment naming context
   2 Context initCtx = new InitialContext();
   3 Context envCtx = (Context) initCtx.lookup("java:comp/env");
   4 
   5 // Look up our data source
   6 String s = (String)envCtx.lookup("SMTP_PASSWORD");

Java/Tomcat (last edited 2014-05-21 22:15:10 by 31)