This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Error  RSS feed

 
bama sabapathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I compiled Servlet file and put the Hello.class file in the Path
C:\apache-tomcat-5.5.17\webapps\ROOT\WEB-INF . and trying to execute http://localhost/Hello in Internet Explorer.It gave the error
HTTP Status 404 - /Hello .I dont know where to put the class file.
Please help me to solve this problem.


Thanks in advance,
Bama
[ June 19, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All classes need to be in a package other than the default.
[ June 19, 2006: Message edited by: Bear Bibeault ]
 
bama sabapathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a directory called "Classes" in WEB-INF dir and copied the hello.class file and executed the servlet file with the path http://localhost/classes/Hello .But it still didn't work.

It gave the error

type Status report

message /classes/Hello

description The requested resource (/classes/Hello) is not available.

What should I do to execute Servlet file.
Thanks,
Bama.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a new folder under C:\apache-tomcat-5.5.17\webapps\ called "test"

Create the following folder structure




And in your web.xml put the following:



Restart tomcat, then open http://localhost/test/hello.html in your web browser

[ June 19, 2006: Message edited by: Lynette Dawson ]
[ June 19, 2006: Message edited by: Lynette Dawson ]
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you notice the bolded part in the sample web.xml i gave you (Hello)? that should be your fully qualified class name (you can leave it as Hello, if you are using the default package)
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bama sabapathi:
I created a directory called "Classes" in WEB-INF dir and copied the hello.class file and executed the servlet file with the path http://localhost/classes/Hello .


It shouldn't be Classes.
It should be classes.
It's case sensitive.

As Bear mentioned, you should put all of your classes in packages.
If you're not sure what that means, you might want to pick up a book on core java or follow some web tutorials. A firm grip on javac, packages, and classpaths will save you a lot of aggrevation when learning servlets.

If an example will help, go to http://simple.souther.us and download the SimpleServlet war file. Drop it in your webapps directory and go to the url listed on site. You will have a properly formed webapp to use as an example.
[ June 20, 2006: Message edited by: Ben Souther ]
 
bama sabapathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really helped.Finally Servlet started working.
Thank You Ben,Dawson and Bear.


Bama.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!