• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Deploy servlet using Tomcat 5

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I m practically new to Servlets.I have written a servlet and i want to deploy it.I m using Tomcat 5 , Jdk 1.5 on windows vista, can any one tell me how to set the classpath and all to compile my servlet.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the javaranch. coming to your question please go to tomcat installation directory and read \webapps\tomcat-docs\deployer-howto.html and \webapps\tomcat-docs\setup.html
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's more to running a servlet than just compiling a single class. Web applications have a fairly complex structure, defined by the WAR architecture specification. So the first thing you need to to is build a WAR. You'd normally want to use some sort of tools to do this, such as Ant or Maven. Some people let their IDEs do all the work, although that's a very poor alternative.

Once you've built a WAR, you need to deploy it. The Tomcat website has very good documentation on WARS and their configuration and deployment. Tomcat itself supports both standards-compliant WAR files and so-called "exploded" WARS, which are whay you'd get if you unzipped a WAR file. There's a "webapps" directory where Tomcat normally expects to put these things, although Tomcat can also find WARs and exploded WARs in other places when configured to do so.

If this sounds like a way to politely say RTFM, well, it is. There's more to the process than we can take the time or space to explain here, so the best we can do is help you find good materials for study. The Tomcat docs at http://tomcat/apache.org are pretty good, but you'd probably want to find some good books on J2EE/JEE and find some local people who know it already and are willing yo help out. Bribery is always useful.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To start from the beginning ...to set the classpath go to the directory where you have deployed tomcat/lib/common/ and copy the address to the environment variable CLASSPATH

then compile your .java file where you have and copy the .class file to the tomcat/webapp/(your directory if any)/WEB-INF/classes
then you include your servlet in WEB-INF/web.xml
open a browser and http://localhost:8080/(your directory if any)/Servlet name

Hope this is what you have asked for
 
AsifAimen Iqbal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Venkat,Tim & Greeshma thanks alot for the help.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go through HFSJ.It's all written there.
 
AsifAimen Iqbal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Well I did not get HFJS but regarding my earlier issue i did set CLASSSPATH and path correctly but when i try to compile it the following errors are coming.

C:\Users\Guest\Desktop>javac BeerSelect.java
BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
BeerSelect.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
BeerSelect.java:5: cannot find symbol
symbol : class io
location: package java
import java.io;
^
BeerSelect.java:7: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
BeerSelect.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,HttpServletResponse response)
^
BeerSelect.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,HttpServletResponse response)
^
BeerSelect.java:9: cannot find symbol
symbol : class IOException
location: class com.example.web.BeerSelect
throws IOException,ServletException {
^
BeerSelect.java:9: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException,ServletException {
^
BeerSelect.java:11: cannot find symbol
symbol : class PrintWriter
location: class com.example.web.BeerSelect
PrintWriter out=response.getWriter();
^
9 errors
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that classpath is not set correctly, it is better to use any IDE like Eclipse.

Thanks,
Deepak.
 
AsifAimen Iqbal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Deepak,
But I want to start with the Basic and i m stuck here dont know what to do.I did set CLASSPATH and path correctly but i have placed my servlet in package is that the reason for the error!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic