aspose file tools*
The moose likes Servlets and the fly likes Servlets not loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets not loading" Watch "Servlets not loading" New topic
Author

Servlets not loading

gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

i am unable to load servlets on my apache as well as on the web http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
I checked it out in that side and it only shows



hai visit my website http://hacktohell.blogspot.com
for tech tips & tricks
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
goow thammm wrote:i am unable to load servlets on my apache as well as on the web http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
I checked it out in that side and it only shows



Hi Goow,

Your question is not clear. I was able to access the link you pasted and I did not get any error. In case, it is throwing error in your local setup, we need to inspect the project setup. What is your project setup?


Thanks & Regards, Ravi C.Kota
SCJP 5.0, OCDJWS 5.0
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

hmmm i am not expert at servlets and stuffand i do not really understand what you are saying but anyway this is what i did.
Installed Apache Tomcat 5.5
wrote and compiled this program with Classpath set

then copied the class file to C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF\classes
then i edited the web.xml file to include my servlet ,the i accessed it from firefox as http:\\localhost:8080\webapps\servlets-examples\HelloServlet
i got an error . the html page i posted in my last post
so i tried an online servlet http://webdev.apl.jhu.edu/servlet/hall.HelloWorld Java servlet .it also did not work!!!
i only get this

<html><head><title>Apache Tomcat/6.0.16 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /servlet/hall.HelloWorld</h1>

type Status report

message /servlet/hall.HelloWorld

description The requested resource (/servlet/hall.HelloWorld) is not available.


<h3>Apache Tomcat/6.0.16</h3></body></html>
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
Hi Goutham,

I'm not sure, if there is any specific reason for using GenericServlet. If you are calling your servlet over HTTP, it is recommended to extend HttpServlet instead.

secondly, I see that you are trying to hit http:\\localhost:8080\webapps\servlets-examples\HelloServlet but, with an assumption that your context is servlets-examples and you mapped your servlet to * in web.xml

your link should be http://localhost:8080/servlet-examples/HelloServlet.

But again, the link "http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/" is fully accessible but not this "http://webdev.apl.jhu.edu/servlet/hall.HelloWorld". For the second link, we don't know how the project is deployed. You may check with the admin of that server and see how the project is setup.
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

even with your link it is not working and i get the same error
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
gowtham sundaar wrote:even with your link it is not working and i get the same error


Which link you are referring to ?
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

http://localhost:8080/servlet-examples/HelloServlet this link
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
We really need to see the contents of you web.xml to give you more help on this.

Also, in what package is you servlet or is it in default package?
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

it is in the default package here is web.xml
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
I would not use default package. It can cause problems.

But your web.xml reveals at least one major issue. You do have the servlet definedbut you do not map it. Add this to mappings:

Also you have much unnecessary stuff in there (like the example filters and such) that may cause problems that prevent the application from deploying successfully. But try first mapping the servlet correctly as I stated above and see if it helps.
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
gowtham sundaar wrote:http://localhost:8080/servlet-examples/HelloServlet this link


Hi Goutham,

the link which I provided is just a sample and it is fake. My intention was, your link should look something similar to that. As Ilari pointed out, start with his advice and slowly incorporate other filters, once you were able to establish the connection. I would advice you to start looking into a simple servlet application with out any filters or listeners, just to get the feeling and have it run successfully before you move on to other components. There are several sites where you can find "Hello World" servlets.

All the best.
gowtham potter
Greenhorn

Joined: Nov 02, 2010
Posts: 27

YAHOOOO . Atlast got my first servlet working!!!
Thank You everybody for your support.
Seemingly i did not map the servlet!!
Ravi C Kota
Ranch Hand

Joined: Jan 29, 2008
Posts: 61
All the best for the rest of the exercises.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Servlets not loading