Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Can not run a servlet class

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)Apache Tomcat/4.1.24,
2)install_dir/webapps/root/web-inf/classes/HelloServlet.class
3)http://host/servlet/HelloServlet
But get HTTP Status 404
What should I do?
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure about the fix,
should (3) be
http://localhost:8080/servlet/HelloServlet ?

Originally posted by newworld kingdom:
1)Apache Tomcat/4.1.24,
2)install_dir/webapps/root/web-inf/classes/HelloServlet.class
3)http://host/servlet/HelloServlet
But get HTTP Status 404
What should I do?

 
newworld kingdom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,the (3) is http://localhost:8080/servlet/HelloServlet
and I removed the comment on
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
but it doesn't work.
Anyone knows this? Thanks lot!
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Better way of doing this:
click here!
 
newworld kingdom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amer and Chi.
not work until now,
by the way,http://localhost:8080 will display
"The page cannot be displayed".
but http://IP address of my machine:8080 is allright. (3) is http://IP address of my machine:8080/servlet/HelloServlet.
Does it matter? and Why I can not use localhost?
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which operating system r u using?
win 2000 or 98

I think there is a problem with your classpath.
 
newworld kingdom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amer,thank you so much,the OS is win2000,
the classpath is .;D:\j2sdk14\lib\tools.jar;D:\Tomcat 4.1\common\lib\servlet.jar;D:\j2sdk14;D:\j2eesdk14\lib\j2ee.jar;D:\j2eeProgram;D:\j2eesdk14
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using jdk1.3.
tomcat installation directory is ---tomcat

CLASSPATH
.;d:\tomcat\common\lib\servlet.jar
HERE tomcat is the name of tomcat installation directory.
PATH
d:\jdk1.3\bin
CATALINA_HOME
d:\tomcat
HERE tomcat is the name of tomcat installation directory.
JAVA_HOME
d:\jdk1.3

OR/and
Edit setclasspath.batch file located at tomcat>bin>setclasspath.batch:
here set java_home like this:
set JAVA_HOME=d:\jdk1.3
This batch file looks like this:
rem ---------------------------------------------------------------------------
rem Set CLASSPATH and Java options
rem
rem $Id: setclasspath.bat,v 1.8 2003/01/17 10:07:21 remm Exp $
rem ---------------------------------------------------------------------------
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJavaHome
set JAVA_HOME=d:\jdk1.3 <---------------------------------------------HERE
:gotJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
goto okJavaHome
[ June 24, 2003: Message edited by: Amer Khan ]
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To confirm your settings
type:
http://localhost:8080/
Enter
u should get the default tomcat home page.
If everything is ok type:
http://localhost:8080/servlet/yourservletclass
 
newworld kingdom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you,Amer!
Now http://63.189.70.202:8080/servlet/HelloServlet is OK, 63.189.70.202 is my PC's IP,but http://localhost:8080/servlet/HelloServlet failed.
Anyway,you solved this problem ! Thanks!
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi newworld,
I am also getting the same 404 error when i am type the url on my browser as:
http://localhost:8080/chapter01/servlet/HelloWorldServlet
Did u find out the problem?
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
have you tried to uncomment the following line in
tomcat-install-dir/conf/web.xml ?
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
it is around line 273 in the web.xml.
HTH
 
Meghasyam Bokam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi chi lin,
Thanks a lot. Now its working after uncommenting the servlet mapping element.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic