• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404 - Servlet is not available

 
hany hashemi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a simple class file named ControllerServlet.Whenever i put it in a default root (in src) my program run successfully. Since i put it in to a seperate package i force with this error:

"HTTP Status 404 - Servlet (control) is not available ..."

I also set the servlet parameters in web.xml.
<servlet>
<servlet-name>control</servlet-name>
<servlet-class>phoneBook.service.ControllerServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>control</servlet-name>
<url-pattern>/control</url-pattern>
</servlet-mapping>

I will appreciate it if anybody can help me.
many thanks
Hany
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What URL are you typing into the browser when trying to hit your servlet?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by hany hashemi:
Whenever i put it in a default root (in src) my program run successfully. Since i put it in to a seperate package i force with this error:

Maybe you didn't put it in the classpath the right way.

I see a capital in your package name, phoneBook. This is unusual in Java, where package names ought to be all lowercase. Verify if anything is right, Java is case sensitive.

If that isn't the problem, then you need to make sure that the folder structure where the class is been put in conforms the package name. I.e. the class must be located at /WEB-INF/classes/phoneBook/service/ControllerServlet.class.

Don't forget to restart the appserver as well.
 
hany hashemi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
thanks for your help.
this is a url for accessing my page:
"http://localhost:8080/control"

I put my file in this location:
web/src/phoneBook/service

Is it wrong location???!!
thanks for helping me
Hany
 
hany hashemi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi again,
I should thank you alot ,i changed the capital letter in package name in to small one and it is working now.
you save me some time...:-)

Hany
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

One comment though:
Originally posted by hany hashemi:
I put my file in this location:
web/src/phoneBook/service

Was you talking about the .java file or the .class file? I was talking about the compiled .class file. It would explain things if you was using an IDE and didn't understood how it works "under the hood". The folder name "/src" is commonly used in IDE's to store the project's raw Java files in. You can find the compiled .class files in the "/build" folder or something straightforward like that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic