wood burning stoves 2.0*
The moose likes Tomcat and the fly likes  Deploying Servlets on tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark " Deploying Servlets on tomcat" Watch " Deploying Servlets on tomcat" New topic
Author

Deploying Servlets on tomcat

Suni Kr
Greenhorn

Joined: Oct 14, 2004
Posts: 11
How do you deploy servlets on tomcat(installed on windows)?what is the command?


SCJP,SCWCD,SCBCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
1. All that you need to know about how to deploy servlets is in documentation that comes with your Tomcat download. Once you have tomcat running, you can read it from your own system.
2. The ranch actually has a Tomcat specific section.
Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60773
    
  65

Moving to the Tomcat forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Suni Kr
Greenhorn

Joined: Oct 14, 2004
Posts: 11
Iam unable to compile my servlet on tomcat.
When I use the javac command it says,

"'javac' is not recognized as an internal or external command,
operable program or batch file."

I have set JAVA_HOME = C:\java-2sdk1.4.2_05
Please tell me what is the problem.
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Suni,

Did you set the PATH? javac can be found under the bin directory.

PATH = C:\java-2sdk1.4.2_05\bin

You can check the value of PATH with the command "echo %PATH%".

Joyce
[ October 15, 2004: Message edited by: Joyce Lee ]
Suni Kr
Greenhorn

Joined: Oct 14, 2004
Posts: 11
Hi Joyce ,
I have set the variable PATH = C:\java-2sdk1.4.2_05\bin but it doesn't show it when I say 'echo %PATH%'.
How can I set it from the DOS window.(there are already some values to the PATH variable so how can I add to it a new value.)

thank you,
suni
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Hi Suni,

To set your Path, you can follow this:

1.Right click on 'My Computer' (from your desktop)
2. Select 'Properties'
3. Select the 'advanced' tab
4. Press the 'Environment Variables' button under System variables scroll till you see 'Path'
5. Select 'Path'
6. Press the 'edit' button - at the very end add, C:\java-2sdk1.4.2_05\bin;

If you want to do it from the DOS prompt,
>set PATH = %PATH%;C:\java-2sdk1.4.2_05\bin
but then when you open a new DOS window, you have to again 'set' this path.

Regards,
Nandini


Discipline, Dedication and Determination define Destiny.
Suni Kr
Greenhorn

Joined: Oct 14, 2004
Posts: 11
Thank for the reply Nandini.I did all that and now my variables are set fine but when I compile the servlet using

"javac -classpath C:\ApacheSoftwareFoundation\Tomcat5.0\common\lib\servlet-api.jar:classes:. -d src\com\example\web\BeerSelect.java"

I get the following error messages:

"src\com\example\web\BeerSelect.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
src\com\example\web\BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.http;
^
src\com\example\web\BeerSelect.java:4: cannot resolve symbol
symbol : class io
location: package java
import java.io;
^
src\com\example\web\BeerSelect.java:6: cannot resolve symbol
symbol : class HttpServlet
location: class com.example.web.BeerSelect
class BeerSelect extends HttpServlet{
^
src\com\example\web\BeerSelect.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{"

And some more similar errors. Please advise me what to do and also tell me what does "...servlet-api.jar:classes:." mean in the above command.
thank you,
Suni.
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Try this:

Assuming you're now in .\example\web directory.

javac -classpath C:\ApacheSoftwareFoundation\Tomcat5.0\common\lib\servlet-api.jar BeerSelect.java


Alternatively, you can set CLASSPATH in Environment Variable just like PATH so that you can compile without the -classpath option. For more info on setting the tomcat, you can check out CoreServlet: Tomcat.

SET CLASSPATH=%CLASSPATH%;.;C:\ApacheSoftwareFoundation\Tomcat5.0\common\lib\servlet-api.jar;


servlet-api.jar consists all the servlet api classes such as HttpServlet, HttpServletRequest. You can view the content of the jar file using "jar tf servlet-api.jar".

For the import, the ending must be either an asterisk or a class name. In JDK 1.5 (tiger), it can end with a static member.

import javax.servlet.http.*;
import java.io.*;


Joyce
[ October 16, 2004: Message edited by: Joyce Lee ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
Once you get away from the simplest servlet examples, the classpath problems get weirder and weirder. Then you should consider building projects with ANT - a considerable learning curve but worth it.
Bill
 
 
subject: Deploying Servlets on tomcat
 
Similar Threads
Web Server and Web container
Restricting request threads in Tomcat
problem with servlet listeners
problem with tomcat4.0.4!!
where to put servlets in tomcat 4.0-b?