Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpStatsuError

 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a HelloWorldServlet under Hello project in the package com.devx.example using Myeclipse


My web.xml is:





I have deployed Hello.war on the Jboss server.

When I am saying like this


http://localhost:8080/Hello/HelloWorldServlet

I got this error:


HTTP Status 404 - /Hello/HelloWorldServlet

---------------------------------------------------------------------------

type: Status report

message: /Hello/HelloWorldServlet

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

Apache Tomcat/5.5.20


Can anyone help me in this case? What is the error I am doing here.


Thanks



[BSouther: Added UBB CODE tags]
[ March 05, 2008: Message edited by: Ben Souther ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few issues that I see.

It's almost always a bad idea to override the service method directly.
Instead override doGet or doPost.

Instead of writing directly to the servletOutputStream, use a printWriter by calling response.getWriter.

Your web.xml heading specifies servlet spec 2.2.
Tomcat 5.5 supports servlet spec 2.4.
This might not be a big problem with this servlet but you are going to run into problems later if you try to learn any of the newer features (filters, listeners, EL, JSTL, etc..).

Lastly, and this is probably what's causing your 404 error, the url-pattern in your mapping specifies /hello but in your url you're requestiong /HelloWorldServlet
Change one or the other.
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed to HelloWorldServlet, but it didn't work. I am getting the same error
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you restart your app after changing it?
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have restarted the app. But still that error is coming
 
abhishek pendkay
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There could be a few issues here
1. When you are starting the Server see if your app loaded fine or it is giving any errors while loading , cause sometimes the app does not load and you get the Not Avaiable error

2. If it is loading fine I belive there is some problem with your web.xml servlet mapping tag. can you show your modified web.xml file
 
Dhana Sen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://localhost:8080/<WebContext/WARName>/URLPatter

In your case URLPattern is Hello

Cheers
Dhana
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic