Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Servlets not loading

 
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
gowtham potter
Greenhorn
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even with your link it is not working and i get the same error
 
Ravi C Kota
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://localhost:8080/servlet-examples/HelloServlet this link
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is in the default package here is web.xml
 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 27
MyEclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the best for the rest of the exercises.
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic