File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes javax.servlet.* package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "javax.servlet.* package" Watch "javax.servlet.* package" New topic
Author

javax.servlet.* package

prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
Hi,

I am reading HF book for servlets and jsp.

I want to code and run the program/tutorial in chapter 3.
I wrote HTML code given on page 75 and it ran fine.
I also wrote the DD given on page 77.

Now I want to write the servlet code on page 80.
But when I say--



I have installed jdk1.5.0_04 and apache-tomcat-5.5.25 .

What more do I need to install in order to import the javax packages?

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You need to set the servlet jar file in your path. Please check this FAQ.


[My Blog]
All roads lead to JavaRanch
Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
hi,
You need to set classpath

i.e. path of servlet-api.jar file in classpath.
This file is present in tomcat\common\lib\ directory.

Regards,
Vilas Lawande
prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
Thanks.

but I have already set my classpath to
C:\Program Files\apache tomcat\apache-tomcat-5.5.25\common\lib

But still I get the compiler error that package javax.servlet.* is not found.
Please help me.


I have another question-
I installed TOMCAT properly, set environment variable JAVA_HOME and TOMCAT_HOME as required , started the Tomcat but when I point my browser to http://localhost:8080/ to see the Tomcat welcome page, I get error -
The page cannot be found

what to do?
[ January 30, 2008: Message edited by: prajal Mehta ]
Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
hi,
It means tomcat is not installed properly.

1.First uninstall tomcat.
2.Set JAVA_HOME to path of jdk only.
3.Install tomcat version
4.Set CATALINA_HOME to path of tomcat only
5.Run tomcat through statup.bat
6.set classpath.
7.proceed
prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
Originally posted by Vilas Lawande:
hi,
It means tomcat is not installed properly.

1.First uninstall tomcat.
2.Set JAVA_HOME to path of jdk only.
3.Install tomcat version
4.Set CATALINA_HOME to path of tomcat only
5.Run tomcat through statup.bat
6.set classpath.
7.proceed



thanks Vilas,

I had set TOMCAT_HOME to path of tomcat (as given in HF book).
Do I need to set CATALINA_HOME path??

Please go through my above post.
Sorry , but I have edited it again.
Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
You have to set CATALINA_HOME.
not tomcat_home.
This must be mistake in HFSJ.If your post is correct.
Regards,
Vilas Lawande.
[ January 30, 2008: Message edited by: Vilas Lawande ]
prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
Originally posted by Vilas Lawande:
You have to set CATALINA_HOME.
not tomcat_home.
This must be mistake in HFSJ.If your post is correct.
Regards,
Vilas Lawande.

[ January 30, 2008: Message edited by: Vilas Lawande ]

Still no luck--
now I have following settigns--

1. I have set the Environment variable CATALINA_HOME to C:\Program Files\apache tomcat\apache-tomcat-5.5.25

2. I have set the JAVA_HOME variable to C:\Program Files\Java\jdk1.5.0_04

3. I have set the classpath to C:\Program Files\apache tomcat\apache-tomcat-5.5.25\common\lib\servlet-api.jar

Now when start the tomcat and point the browser to http://localhost:8080/ I get "The page cannot be found " error.
And also the compiler error (package not found ) for import javax.servlets.*

please help
I am clueless


Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
You have not followed sequence as I mentioned.
I think you have follow all steps mention by me in previous post.
Or you have to change setup of tomcat.


for classpath: set like this:

veriable name: classpath
veriable value:%classpath%;.;C:\Tomcat5.0\common\lib\servlet-api.jar;
It must work fine.
[ January 30, 2008: Message edited by: Vilas Lawande ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

but I have already set my classpath to
C:\Program Files\apache tomcat\apache-tomcat-5.5.25\common\lib

You didn't read the link I've posted above.
prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
Christophe , yes I did read that link

I must have messed up the installation of Tomcat previously.
1.Now I reinstalled the Tomcat
2. I set up the JAVA_HOME , CATALINA_HOME to required locations.
3. I started the Tomcat.
4. I set the CLASSPATH variable to -->
%CLASSPATH%;C:\Program Files\apache tomcat\apache-tomcat-5.5.25\common\lib\servlet-api.jar

Now the http://localhost:8080/ does show the welcome page

But import javax.servlet.* is still giving error
(I am using Eclipse for writing servlets)

Please somebody help me
prajal Mehta
Ranch Hand

Joined: Dec 03, 2007
Posts: 66
hi again..

When I use command line to compile my servlet program it gets compiled fine.

The problem must be with the settings of the tool I am using -- Eclipse
I tried setting up preferences--classpath variables but it's not working.

This thread has become too long , I shall open a new thread to get help regarding setting of tools


thanks all for helping me.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Everyone has assumed that you are not using Eclipse because:
1) For studies it is recommended to not use an IDE... at least to start out
2) You never said you were using it.

If http://localhost:8080/ is not working, then Tomcat simply isn't working or you're trying to run an instance of it from within Eclipse. I'm pretty sure that the default applications that come with Tomcat do not run if you are running Tomcat from within Eclipse.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.servlet.* package