• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

javax.servlet.* package

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to set the servlet jar file in your path. Please check this FAQ.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic