|
Tomcat
Servlet
Set Up
Viewing
the Tomcat Logs
Connect
jsp <> mysql
Restarting
Tomcat
MySQL
Creating
MySQL Database
For more help on MySQL please
login to the control panel of your website by going
to: www.yourdomain.com/admin/ and follow the HELP link.
Servlet
Set Up - READ CAREFULLY
To setup servlet, you
need to configure servlet into the file web.xml which
needs to be placed in /var/www/html/WEB-INF directory.
www root directory or webapps:/var/www/htm
Classes directory located in: /var/www/html/WEB-INF/Classes/
There you will need to upload your Java class file.
Our default url-mapping for servlet is: /servlet/*
To check servlet in your browser: www.mydomain.net/servlet/HelloWorld
Jsp Files - Upload anywhere in /var/www/html
DOUBLE CHECK:
Double Check that that url-mapping for servlers is entered
corectly in web.xml
Double Check that Java class file is uploaded in the
corect place.
Without these two things your servlet will not work.
Viewing
Tomcat Logs
By default all the logging activity will be placed within
the /var/log/ directory of your application. If a ssh
shell is enabled on your account then 'tailing' the
logs can provide a powerful tool in debugging your web
application.
Viewing the logs is recommended when you suspect that
errors are occurring during the loading/reloading of
your web application.
To get SSH acces you'll
need to request it, it is not enabled by default on
all accounts.
Connect
jsp <> mysql
Example
Please make sure that
you have created database through the control panel
and that you have setup password for db. Write down
your database name - this is very important !
Instructions for database set up available in your initial
account activation email titled " MySQL Set Up
Instructions"
After this steps, edit dbtest.jsp and enter correct
informations, upload this two files and test them
This is an example with
org.gjt.mm.mysql.Driver MySQL driver. We also
support com.mysql.jdbc.Driver
--------------------------------------------------------------------------------
File 1: dbtest.jsp
<%
String dbhost1 = request.getParameter("dbhost");
String dbname1 = request.getParameter("dbname");
String user1 = request.getParameter("user");
String pass1 = request.getParameter("pass");
if( dbhost1==null )
dbhost1="localhost";
if( dbname1==null )
dbname1="ENTER=HERE-YOUR-DB-NAME";
if( user1==null)
user1="YOUR-USER-NAME";
if( pass1==null )
pass1="MYSQL-PASSWORD";
%>
<form action="dbsubmit.jsp"
method=get>
<table>
<tr>
<td>dbhost
<td><input size=60 name="dbhost"
type=text value="<%=dbhost1%>">
<tr>
<td>dbname
<td><input size=60 name="dbname"
type=text value="<%=dbname1%>">
<tr>
<td>user
<td><input name="user" type=text
value="<%=user1%>">
<tr>
<td>password
<td><input name="pass" type=text
value="<%=pass1%>">
<tr>
<td colspan="2">
<input type=submit>
</table>
</form>
------------------------------------End
of dbtest.jsp
--------------------------------------------------------------------------------
File 2 - dbsubmit.jsp
<%
String dbhost = request.getParameter("dbhost");
String dbname = request.getParameter("dbname");
String user = request.getParameter("user");
String pass = request.getParameter("pass");
String connURL =
"jdbc:mysql://"+dbhost+"/"+dbname+"?user="+user+"&password="+pass;
try
{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
java.sql.Connection conn = java.sql.DriverManager.getConnection(connURL);
response.getWriter().println("<font color=green><b>");
response.getWriter().println("Connection success!!!");
response.getWriter().println("</b></font>");
}
catch(Exception e)
{
response.getWriter().println("<font color=red><b>[");
response.getWriter().println(e.getMessage());
response.getWriter().println("]<br>");
response.getWriter().println("Connection URL:["+connURL+"]");
response.getWriter().println("</b></font>");
}
%>
<%@include file="dbtest.jsp"%>
--------------------------------End of dbsubmit.jsp
Restarting
Tomcat
Shared Tomcat Plan: You'll
need to email us and we'll restart the Tomcat for you.
Private Tomcat Plan: Restart Tomcat via SSH access.
Setting
Up MySQL Database
Go to www.yourdomain.com/admin/ and login
to your account
------> Follow the MySQL link
2.Create a database
3. Write down database name
4. Set up database password
Our MySQL address (hostname)= "localhost"
|