• 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

Deploying Servlets on tomcat

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you deploy servlets on tomcat(installed on windows)?what is the command?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Tomcat forum.
 
Suni Kr
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Suni Kr
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic