Jump to main contentmickwood.com - Website Hosting & Design for Christian Organisations
Support

"If we don't know it's broken we can't fix it!"

Support FAQ Homepage

Can't find the answer?

Python & Java Servlets

  1. How do I connect to a MySQL database from a Java script using JDBC?
  2. How do I deploy a .war archive?
  3. How do I restart the Java Servlet service?
  4. How do I run Python scripts?
  5. How do run I Servlets and JSP scripts on my web site?
  6. What version of Java Servlet software is supported?
  7. What version of Python is supported?

1. How do I connect to a MySQL database from a Java script using JDBC?

Upload the file mm.mysql-2.0.14.jar to the directory /WEB-INF/lib on your web site. Use the following JDBC code in your scripts to connect to your MySQL database.

<%@ page import="java.sql.*" %>
Connection connection = null; 
Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
connection = DriverManager.getConnection( "jdbc:mysql://localhost/DATABASE_NAME?user=DATABASE_USERNAME&password=PASSWORD");

Replace "DATABASE_NAME" with the name of your MySQL database, "DATABASE_USERNAME" with the user assigned to the database, and "PASSWORD" with the password of the user.

Back to top


2. How do I deploy a .war archive?

There are 3 ways to deploy a Java .war archive.

1)Upload the .war file to your web site and execute the command "unzip filename.war" while logged into your site via SSH.

Command:

 [username@server ~]$ unzip example.war
Archive: example.war
creating: META-INF/
inflating: META-INF/MANIFEST.MF
inflating: helloworld.jsp
creating: WEB-INF/
inflating: WEB-INF/web.xml
inflating: index.html

2) Send an email to mick@mickwood.com with the .war file as an attachment. We'll upload the file to your site's work directory and Tomcat will unpack the file for you.

3) Upload the .war file to your web site and access it via the URL http://domain.com:8080/filename

NOTE: Before you deploy a .war archive, Java Servlet support needs to be enabled on your web site. (See Q5 below)

Back to top


3. How do I restart the Java Servlet service?

Send a request to mick@mickwood.com asking for Tomcat service to be restarted. Make sure to include your domain name in the request.

Back to top


4. How do I run Python scripts?

To run a Python script from a shell, execute the command:

/usr/bin/python /path/to/script.py

To run a Python script from a web browser first upload a file named .htaccess to your public_html directory with following contents:
 

Options +ExecCGI
AddHandler cgi-script .py

Then sure your script ends with .psp or .py, upload it to your web site, chmod it to 755, and then access it in a web browser. Below is a simple example script that you can use to test Python functionality.

<html> 
<% 
import time 
%> 
Hello world, the time is: <%=time.strftime("%Y-%m-%d, %H:%M:%S")%> 
</html>

If you need assistance setting up Python scripts on your web site, please email mick@mickwood.com.

Back to top


5. How do I run Servlets and JSP scripts on my web site?

The first thing you'll need to do is send a request to mick@mickwood.com, requesting for Java Servlets to be enabled on your web site. Please make sure to provide your domain name in the request.

After Java Servlets have been enabled on your web site, a directory called WEB-INF will be created in your public_html directory. Inside the WEB-INF directory is a file named web.xml which contains configuration information, a directory called classes and a directory called lib.

Class Path: /WEB-INF/classes
Lib/Jar Path: /WEB-INF/lib
Configuration file: /WEB-INF/web.xml

The /classes directory is where your Class files(.class) and Java files(.java) should be uploaded. The /lib directory is where your Jar(.jar) files should be uploaded.

Regular Java scripts that end with the .jsp extention can be run in any directory on your web site.

 

Back to top


6. What version of Java Servlet software is supported?

We run Tomcat version 5.0.19, which supports Servlet 2.4 and JSP spec 2.0.

Back to top


7. What version of Python is supported?

We support Python version 2.2.3 on all of our web servers.

Back to top


welcome | name | hosting | design | content | promote | update | showcase | support | general information

Showcase Update Promote Content design Hosting Name Welcome