File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Basic Doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Basic Doubts" Watch "Basic Doubts" New topic
Author

Basic Doubts

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
Hi all,

I have a basic knowledge in Java and I want to learn the JSP and Servlet.
I have one doubt, for running JSP & Servlet, the below things are needed.

1. JDK 1.x (Set the path for /jdk1.x/bin & JAVA_Home for /jdk1.x)
2. Tomcat 4.x or 5.x (what to set & how to set)

Since I had already worked in java, i know how to set java path. For running JSP & servlets, whether we have to set CATALINA_HOME, TOMCAT_HOME.

I want to know why the following paths are set:

1. SET PATH
2. SET CLASSPATH
3. SET JAVA_HOME
4. SET CATALINA_HOME
5. SET TOMCAT_HOME

Is there any other paths are there to set. If so, pls tell me even if it is not necessary to run JSP & Servlet. Just I want to know what are the paths are there and why they are using?

Another doubt is whether to run JSP & Servlet, Tomcat is enough. Why we have to use Apache Web Server. What is it?. Our JSP & Servlet will be handled by Tomcat. What is differences between Apache Web Server and Apache Tomcat?

Thanks in advance,

Regards,
Mark.
[ July 14, 2005: Message edited by: Bear Bibeault ]
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
Read the documentation that comes with Tomcat - CATALINA_HOME etc is discussed there.

Tomcat 5.x requires you have the Java 5 JDK installed, the earlier version only needs Java 1.4x.

You don't need Tomcat and Apache to run JSP/Servlets. But you will need Tomcat. Apache is an Http server and does not have a Java container.
Nagarajan Krishnamurthy
Greenhorn

Joined: Sep 26, 2003
Posts: 20
Set Path :
This one loads the entire directory what u have specified while the system boots.Thereby making all the files accessible from any directory.
ex., We use this one to set the bin directory after installing jdk

Set Classpath:
This one is used to map a particular file
ex.,jar,lib files...

If u were using the Apache's 5.xx version server the only thing what u may have to set is JAVA_HOME which should point to the jdk's bin folder
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Steve McCann:
Read the documentation that comes with Tomcat - CATALINA_HOME etc is discussed there.

Tomcat 5.x requires you have the Java 5 JDK installed, the earlier version only needs Java 1.4x.

You don't need Tomcat and Apache to run JSP/Servlets. But you will need Tomcat. Apache is an Http server and does not have a Java container.


A little clarification:
Tomcat 5.5x requires Java 5 or j2sdk1.4 with the compat libraries.
Tomcat 5.0 and lowere can run with j2sdk1.3x

Apache is the foundation under which both Tomcat and HTTP Server reside.
The HTTP Server (formerly HTTPD) is commonly referred to as "Apache" because it is their most prominent project.

Depending on how you install Tomcat, you may not need to set any environment variables. To compile your servlets though, you'll want servlet-api.jar (found in {tomcat}/common/lib) on your CLASSPATH.

Your first point was the most important, and was dead on.
If you're just starting out with Tomcat, the best place to learn about installing and configuring it is the Tomcat documentation.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/index.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
I seen the documentation and accordingly installed and set the path. But, I'm getting the same error. I given the issue in detail.

Following is the path I have set:
---------------------------------
SET PATH="C:\Program Files\Java\jdk1.5.0_04\bin;"%PATH%
SET JAVA_HOME="C:\Program Files\Java\jdk1.5.0_04;"%PATH%
SET CLASSPATH="C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar;"%PATH%
SET CATALINA_HOME="C:\Program Files\Apache Group\Tomcat 4.1;"%PATH%

Environment
----------
1. OS: Windows 98 SE
2. It is Not connected to any Network.
3. Tomcat 4.1
4. JDK1.5.0

I am using Head First Servlet & JSP book.
When I tried to compile the below servlet, I am getting error.



Saloni Mangla
Greenhorn

Joined: Apr 19, 2005
Posts: 3
Mark,
You can try compiling your code using the classpath as the compiler option.
for example if your classpath = ;c:\javacode;c:\tomcat\common\lib\servlet.jar where c:\javacode has the source code (.java) file
then in the command window type this

c:/javacode> javac -classpath ";c:\javacode;c:\tomcat\common\lib\servlet.jar " HelloWorld.java

I have tried this and it worked for me. Let me know how it goes for you.

Good Luck
Saloni.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I seen the documentation and accordingly installed and set the path. But, I'm getting the same error. I given the issue in detail.

Following is the path I have set:
---------------------------------
SET PATH="C:\Program Files\Java\jdk1.5.0_04\bin;"%PATH%
SET JAVA_HOME="C:\Program Files\Java\jdk1.5.0_04;"%PATH%
SET CLASSPATH="C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar;"%PATH%
SET CATALINA_HOME="C:\Program Files\Apache Group\Tomcat 4.1;"%PATH%


Why are you appending your system path to the end of all the other environment variables?

If you download and install the ".exe" version of Tomcat on Windows, you won't need to set any environment variables.
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200


To Saloni Mangla


My servlet code is in D:\javacode.
Name of the servlet is BeerSelect.java

D:\Javacode>javac -classpath ";d:\javacode;c:\progra~1\apache~1\tomcat4.1\common
\lib\servlet.jar" BeerSelect.java

But still iam getting the same error.



To Ben Souther

Yes I had installed the following exe in the windows 98 SE
jakarta-tomcat-4.1.31.exe
After installation, I found tomcat4.1 folder under c:\program files\apache group\tomcat4.1
So you are telling no need to set any environment variables.

No need to set the JAVA_HOME, CLASSPATH, CATALINA_HOME. While installing itself it will be automatically set? If so, why I am getting the error.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Mark,

It definately looks like a classpath problem.
Have a look at the Javaranch classpath faq, that may help.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Mark Henryson:

To Ben Souther

Yes I had installed the following exe in the windows 98 SE
jakarta-tomcat-4.1.31.exe
After installation, I found tomcat4.1 folder under c:\program files\apache group\tomcat4.1
So you are telling no need to set any environment variables.

No need to set the JAVA_HOME, CLASSPATH, CATALINA_HOME. While installing itself it will be automatically set? If so, why I am getting the error.


No, they're not set at all. The .exe version stores all this information in the Windows registry.

Note, from my first post in this thread:

Depending on how you install Tomcat, you may not need to set any environment variables. To compile your servlets though, you'll want servlet-api.jar (found in {tomcat}/common/lib) on your CLASSPATH.
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
So it is a problem in the Classpath setting.

I have to set the classpath for servlet.jar for running Servlet and JSP.

My servlet.jar file is in C:\Program Files\Apache Group\Tomcat4.1\common\lib\servlet.jar

In MS-DOS if type
c:\>cd program files
It displays too many parameters.

If I type
c:\>cd progra~1
It dosen't display error.

That's why I had set the classpath like this:
SET CLASSPATH= ;C:\Progra~1\Apache~1\Tomcat4.1\common\lib\servlet.jar

Whether any problem is due to Progra~1 and Apache~1
Susmita Pal
Ranch Hand

Joined: Jul 12, 2001
Posts: 31
I think you should just cut out the whole Tomcat4.1 folder to C:\Tomcat.... and set the classpath as c:\tomcat4.1\common\lib\servlet.jar
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Originally posted by Mark Henryson:

My servlet.jar file is in C:\Program Files\Apache Group\Tomcat4.1\common\lib\servlet.jar

That's why I had set the classpath like this:
SET CLASSPATH= ;C:\Progra~1\Apache~1\Tomcat4.1\common\lib\servlet.jar

Whether any problem is due to Progra~1 and Apache~1


Not sure if this will work, but try enclosing your classpath in "quotes", if it contains spaces.

HTH
Saloni Mangla
Greenhorn

Joined: Apr 19, 2005
Posts: 3
Hi Mark,
It is definitely a classpath issue, try to install tomcat in a 'no space' folder, as in instaed of programs/....
install it in c:/tomacat and accordingly set the path. I did the same when i was trying to compile my piece... this might help it work.. and then u will not need those qoutes "" at all.
u can simply say

d:\javacode> javac -classpath ;d:\javacode;c:\tomcat\common\lib\servlet.jar BearShare.java

in this case
your system variable will be as
classpath= .;d:\javacode; C:\tomcat\common\lib\servlet.jar
path = %PATHA%;d:\java\bin;
java_home=d:\java
catalina_home=c:\tomcat

It should not matter but just out of curiosity, y have you installed jdk and tomcat on different drives?

Hope all this works, let me know
good luck
Saloni.
 
GeeCON Prague 2014
 
subject: Basic Doubts