Home | Order Now | Support
Tomcat Java JSP Web Hosting Company India, Hyderabad
CALL US: +91 9391 323639
Email: info@websitedesignindia.in
Web hosting hyderabad
 
Linux Server Hosting India Windows Server Hosting India Domain Names Website Designing Hyderabad Hosting FAQ's Contact Us Hosting Help
Tomcat Hosting Support
Linux Support Windows Support Tomcat Server
For Support send email to support@websitedesignindia.in
1. JSP & Servlet Operation
2 How to deploy WAR file
3. Deploying JSPs & Servlets
4. Tomcat Restart Tool (Instant)
5. MySQL / JDBC connection
6. Using JavaMail
7. JSP/Servlet processing
8. MySQL Connection Pool
9. Sending email from JSP
10. How to connect using SSH
   
1. JSP & Servlet Operation

cPanel (with the mod_jk module) has JSP and servlet functionality enabled on the Apache Web server. The Tomcat engine executes JSP and servlets. Once Tomcat is enabled for a site, cPanel instructs the Web server to send certain requests to Tomcat for processing. Tomcat requires an execution environment known as context, to be set up before it can execute JSPs and servlets properly.

A context is a directory structure on the server from which Tomcat can execute servlets and JSPs. cPanel automatically sets contexts for you. Please, note: we do not support Web archives (.war files).

TOP
2. Deploying JSPs & Servlets

Deploying JSPs and servlets on the cPanel is as easy as uploading a Web site using any FTP client. When Tomcat hosting is enabled for a site using, cPanel creates a default Tomcat context, for the virtual site in the site's web directory.

The context path of each virtual site is: "/home/domain/public_html/WEB-INF".

The WEB-INF directory contains configuration information for Tomcat and is the directory in which servlet class files need to be placed for deployment.

For more information, please visit the official Tomcat5 site at:

http://tomcat.apache.org/tomcat-5.5-doc/

Notes:

1) There is only one WEB-INF available per site - available for your main domain (www.yourdomain.com or domain.com); you can NOT have support for JSP pages and servlets for any sub-domains.

2) We support WAR deployment only for private JVM instance. Currently we do NOT support WAR with our shared JVM plans due to common problems related to incorrect path names in the actual WAR archives. You can deploy your application files via FTP or by using our Web File Manager, and you can deploy any XML or class files in the WEB-INF folder.

3) To restart your Tomcat, you can use the provided automatic Tomcat restart tool which is available under the “Software” section of your cPanel.

TOP
3. Tomcat Restart Tool (Instant)
Our cPanel comes with an automatic Tomcat restart tool which you can use to restart the Tomcat service. The tool is available under the Software section of your cPanel

Please note that the tool will restart the Tomcat instantly.

TOP
4. MySQL / JDBC connection

MySQL / JDBC connection

To connect to your MySQL database under Tomcat you can use the JDBC driver which is already included with our Tomcat instance.

You can use JDBC to connect to your MySQL. An example code is provided below:

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost/yourdatabase
userName=your_mysql_user
password=your_mysql_pass

Below is an example of a simple JSP code working with MySQL via JDBC:

<%@ page import="java.sql.*" %>
<%
String username="your_mysql_username";
String password="your_mysql_username_password";
String dbName="your_complete_database_name";
String dbHost="localhost";
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException msg) {
out.println("Error loading driver:" + msg.getMessage());
}

try{
String url ="jdbc:mysql://"+dbHost+":3306/"+dbName;
Connection Conn = DriverManager.getConnection(url,username, password);
Statement Stmt = Conn.createStatement();
String query = "select now()";
ResultSet res = Stmt.executeQuery(query);
while(res.next())
{
out.println("Query result : "+res.getObject(1));
}
} catch(SQLException e) {
String err1Msg = e.getMessage();
%>
<TD COLSPAN="2"><STRONG><EM>err1Msg = <%= err1Msg %></EM></STRONG></TD>
<%
}
%>

Please note that the MySQL connector is NOT loaded by default and you need to add any necessary MySQL connectors to your instance in order for your site to connect to MySQL through JDBC

TOP
Using JavaMail

You can use javamail to send out emails from your JSP code and using our local smtp server. Please note that you need to specify the port number for javamail within your code to be port "125" or port "2525" ( mail.smtp.port=125 ) instead of the standard port 25 otherwise your emails will not go through.

IMPORTANT: In order to use our SMTP service you need to set your code to require Authentication and you need to authenticate through your code using an email account (email@yourdomain.com) and password which exist in your domain name hosted with us. You need to create your email account first using the provided cPanel/Plesk control panel.

TOP
JSP/Servlet processing

In order for your servlets/JSP code to work - you need to make sure that you setup your Apache (IIS) to Tomcat mappings through the provided Domain Mapping feature avaialble inside your NGASI control panel. The Domain mapping feature in NGASI is located at the top right corner of your NASI interface (2nd icon from the left). The same applies for any WAR files being deployed - you need to make sure that the mapping of the file is set through NGASI once the application is deployed.

TOP
MySQL Connection Pool

If you'd like to setup a database connection pool through JNDI for your MySQL database - please setup your database, database username and password and provide us with XML file like the sample below

* Note this applies only if you are a shared Tomcat client, if you have your own private JVM then you can setup this context directly through your Tomcat configuraiton files


<Resource name="jdbc/SampleDB" auth="Container"
type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/Sample_Database"
username="mysql_user" password="mysql_pass" initialSize="1" maxActive="30" maxIdle="30"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true"
validationQuery="select now();" />

You can either email us your XML file to info AT websitdesignindia.in or attach it through our support system or simply upload it to your public_html folder and contact us so that we can set it up for you.

TOP
How to deploy WAR file

You can deploy a WAR file either through your Tomcat Manager application or by simply uploading your WAR file in the following directory:

appservers/apache-tomcat-xx/webapps

Where you replace apache-tomcat-xx with the actual Tomcat directory created after your Tomcat instance has been installed.

Please note that the Tomcat will auto deploy your WAR files. You need to make sure that your Tomcat is installed and running before it can auto deploy your WAR

TOP
Sending email from JSP

To send a Mail you can use a java.mail class. If you are using a shared tomcat mail.jar and activation.jars are included by default.
If you are using a private tomcat You need to upload them into your global lib directory or WEB-INF/lib application directory.

An example code how to use java.mail is provided below:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.Properties"%>
<%@page import="javax.mail.Session"%>
<%@page import="javax.mail.Authenticator"%>
<%@page import="javax.mail.PasswordAuthentication"%>
<%@page import="javax.mail.Message"%>
<%@page import="javax.mail.internet.MimeMessage"%>
<%@page import="javax.mail.internet.InternetAddress"%>
<%@page import="javax.mail.Transport"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Email Test</title>
</head>
<body>
<%
String smtpServer = null;
String smtpPort = null;
final String authAddress = request.getParameter("auth_add");
final String authPassword = request.getParameter("auth_pass");
String subject = null;
String email = null;
String message = null;
String send = request.getParameter("send");
String siteName=request.getServerName();
siteName=siteName.replaceAll("www.","");

if(send!=null){
smtpServer = request.getParameter("smtp_server");
smtpPort = request.getParameter("smtp_port");
subject = request.getParameter("subject");
email = request.getParameter("email");
message = request.getParameter("message");
try{
Properties props = new Properties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.port", smtpPort);
props.put("mail.smtp.auth", "true");

// create some properties and get the default Session
Session sessionMail = Session.getInstance(props, new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(authAddress, authPassword);
}
});

sessionMail.setDebug(true);

// create a message
Message msg = new MimeMessage(sessionMail);

// set the from and to address
InternetAddress addressFrom = new InternetAddress(authAddress);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[1];
addressTo[0] = new InternetAddress(email);
msg.setRecipients(Message.RecipientType.TO, addressTo);


// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader("site", siteName);

// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}catch(Exception e){
e.printStackTrace(response.getWriter());
}
}
%>
<form name="emailForm" action="email-test.jsp" method="post">
SMTP Server: <input type="text" name="smtp_server" value="mail.<%out.print(siteName);%>"><br>
SMTP Port: <input type="text" name="smtp_port" value="2525"><br>
Username: <input type="text" name="auth_add" value="change_me@<%out.print(siteName);%>"><br>
Password: <input type="password" name="auth_pass"><br>
Subject: <input type="text" name="subject" value="Test SMTP Server."><br>
Recipient: <input type="text" name="email" value=""><br>
Message Body : <input type="text" name="message" value="Test"><br>
<input type="submit" name="send" value="send">&nbsp;
<input type="Reset" name="reset" value="reset"><br>

</form>
</body>
</html>

TOP
How to connect using SSH

First of all you will need to get your SSH account information, this can be found
in Control Panel under Webspace/Access -> FTP Account.

You are going to need an SSH Client. We recommend a program "PuTTY". It is a free
program that gives you SSH access.

The Host Name will be yourdomain.com and you need to change the Protocol from Telnet
to "SSH" (Port 22).
You can save the session by giving it a name. This will save having to enter
this information each time you want to use SSH!

When you type the password that is provided to you for the control panel. it will not be visible when you type. You need to type the pasword and press enter and it will be connected.

Once the server is connected you need to execute
To shutdown, execute: ~/tomcat/bin/shutdown.sh
To startup execute: ~/tomcat/bin/startup.sh

 

 


TOP
 
 Other Packages on Linux Server

 

 Control Panel Demo
Control Panel Demo Linux Server
 
 
 Server Configuration
We stay on top of the latest technologies, and try to utilize the latest server hardware specs available on the current market.

We are currently utilizing the latest Dell PowerEdge servers with at least a minimum of:

1) Dual Quad Core Xeon CPUs
2) 8GB of RAM
3) Redundant (RAID) SAS (SCSI) 15K RPM drives

Our Server are monitored 24/7, using the latest technologies available, and apply strict security policies to make sure that your information is always available to you and your clients while maintaining safety and confidentiality.


Our data centers (SAS 70 Type II Certified, located in Dallas and Houston, Texas) are equipped with multiple backbone Internet lines, backup power diesel generators, backup tape libraries, 24/7 surveillance ensuring speed, safety, and redundancy.

 
2008 @ Website Design India. All rights reserved. Sitemap | Privacy Policy | Terms & Conditions | Resources | FAQ | Contact Us
Tomcat Java JSP Web Hosting Company India, Hyderabad, Chennai, Mumbai, New Delhi, Nagpur, Calcutta, Pune, Bangalore, Amritsar, Ahamdabad, Vijayawada, Jaipur