• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

simple question

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am newbie to Servlets, JSP and Tomcat.
all I want to do is run my servlet HelloWorldServlet on the browser
i.e: http://localhost:8080/servlet/HelloWorldServlet
I am getting http status 404 error:
type: Status report
message /servlet/HelloWorldServlet
description The requested resource (/servlet/HelloWorldServlet) is not available
I have HelloWorldServlet.class in
C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes
My classpath:
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;
My tomcat_home:
C:\Program Files\Apache Tomcat 4.0\bin
Any help is appreciated
Ravi
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to put your servlet into a package. Then you should be able to
request it via http://machine ort/servlet/package/Servlet.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ravi...
try this URL in your browser
http://localhost:8080/examples/HelloWorldServlet
and if this doesn't work (it has to work if there is nothing else wrong... ) then check ur Web.xml file inside your WEB-INF directory.
there should be two entries..


hope this helps you... in case of dooubt please revert back..
Thanks
Amit
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on where your classes are, this should work.
http://localhost:8080/examples/servlet/HelloWorldServlet

As already posted though, it's better to have a web application and then use its web.xml to configure how your servlets are accesed.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I had the same problem and even i am new to all those u mentioned.
But i solved that problem by making sure whether the tomcat installation is done properly, check the port where ur running the tomcat server first.
I use NetBeans IDE, so i exported a war file including all files and dropped in tomcat's webapp's folder and then browse.
http://localhost:8080/warfilename/path in URL mapping of web.xml file
It should work, hope it would help for you.
 
swapna Kadali
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In general, it is suggested you to install tomcat in

C:/Jakarta/Tomcat4.0 ( according to my professor) without any blank spaces in the folder.
 
Saloon Keeper
Posts: 26294
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, in Tomcat 4 and later, you can't invoke a servlet that's not defined in a web.xml file (no drop-and-go). This is a security feature.
 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the help.
I did not restart my server after registering my servlet.
Thanks
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
I joined the forum today only .Hope my answer helps you out.All you need to do is to have a web.xml file in /mainwebapp/WEB-INF which will look something like this.
<servlet>
<servlet-name>
AssignmentCookie
</servlet-name>
<servlet-class>
AssignmentCookie
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
AssignmentCookie
</servlet-name>
<url-pattern>
AssignmentCookie
</url-pattern>
</servlet-mapping>
</web-app>
All u have to do is to replace the assignmentCookie by your file name.
Hope it helps you.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic