Adding a Java Servlet to Your Web Site
To deploy a servlet, you first need to compile it at your local box. Next, you can upload the class file to WEB-INF/classes directory. You should then be able to run it by entering the URL http://www.coolexample.com/servlet/yourservletname, where "www.coolexample.com" is the URL for your website.
Alternatively, you may package the servlet into a jar file and upload the jar file to the WEB-INF/lib directory. However, if you choose to use a jar file, you must wait for Tomcat to restart at its scheduled time before you see the servlet.
You can place the main configuration file, web.xml, in the WEB-INF/ folder. The web.xml file tells Tomcat how to handle servlet requests and where to direct URLs. Tomcat reads the file when it restarts.
The war file automatically explodes to the subfolder of the same name under your home directory and will deploy overnight.
NOTE: If your code is invalid or you attempt to violate security policies, your server will be disabled. For example, writing or reading to a directory other than /tmp, attempting to connect to a host that is not defined as an allowed host/port, and using the log4j module would be considered a violation. For directories Tomcat, Java, or Java Servlet pages disable, the pages will not load until the server is restarted the next morning.
Do I get my own WEB-INF directory?
Is my Java-enabled hosting account running in a shared JVM or a private JVM?
What SMTP server can I use with JavaMail?
Can I restart the Tomcat service on my Linux shared hosting account?
Which version of Tomcat do you use on your Java-enabled hosting accounts?
Connecting to a MySQL Database on Your Linux Hosting Account Using JSP
Have a question about the content of this article?
Sending Message...
0 min expected wait time