This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Servlet example - error 404: how to resolve? (what is wrong?)  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm new here and can't find the answer.
I move my application from Tomcat 4 to Tomcat 6. My servlets work fine in Tomcat 4 and doesn't work in Tomcat 6 (of corse, I compiled it with new Java version, and most classes work fine).

The servlets make me problem structure is very similar to ChatServlet example that is configured in web.xml as following:

<servlet>
<servlet-name>ChatServlet</servlet-name>
<servlet-class>chat.ChatServlet</servlet-class>
</servlet>
.......
<servlet-mapping>
<servlet-name>ChatServlet</servlet-name>
<url-pattern>/jsp/chat/chat</url-pattern>
</servlet-mapping>

When I try to run it, it gives me 404 error:

--------------
http://localhost/examples/servlets/servlet/chat.ChatServlet

HTTP Status 404 -
type Status report
description The requested resource () is not available.
--------------

The simple examples like http://localhost/examples/servlets/servlet/HelloWorldExample etc run well.

Please help! I'm some days and can't understand what is wrong: link, configuration or my had.

Thanks in advance!




 
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You set up a mapping for the servlet, and then you didn't use it. So of course it's not going to work.
 
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to access the servlet named as ChatServlet? If so, what should be your url to invoke that servlet? Check it!
 
Ranch Hand
Posts: 247
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hit it using the URL you have set "/jsp/chat/chat"... This URL refers to the servlet with the name "ChatServlet"... Meanwhile, Please use correct names for URL Paths...Since you are using servlets, use prefix names "servlet" in url...
 
Bear Bibeault
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ram Narayan.M wrote:Since you are using servlets, use prefix names "servlet" in url...


No, don't. That's an old-fashioned habit left over from the days of the Invoker and is a poor practice. The URL should not specify implementation details.

On the other hand, the prefix "jsp" is just as bad, if not worse.
 
Bear Bibeault
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ram Narayan.M wrote:Hit it using the URL you have set "/jsp/chat/chat"...


That will only work if the app is deployed as the ROOT application. In general it must be prefixed with the context path.
 
Julia Shreiber
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You set up a mapping for the servlet, and then you didn't use it. So of course it's not going to work.



Exactly. I guess I don't know how to use it, this is the question

Ram Narayan.M wrote:Hit it using the URL you have set "/jsp/chat/chat"... This URL refers to the servlet with the name "ChatServlet"... Meanwhile, Please use correct names for URL Paths...Since you are using servlets, use prefix names "servlet" in url...



Do you mean to use link http://10.0.0.8:8080/examples/servlets/servlet/jsp/chat/chat/ChatServlet ? I tried, it gives the same result.

Bear Bibeault wrote:That will only work if the app is deployed as the ROOT application. In general it must be prefixed with the context path.



It is deployed in Tomcat\webapps\ezface-prod\WEB-INF - it is example of Apache. Other servlets deployed in the same place but more simple work fine.

I guess the problem is in using. I can't find example how to call this servlet. I tried to use it similar to simple examples like HelloWorldExample but something is wrong in my call.

http://localhost/examples/servlets/servlet/HelloWorldExample - works
http://localhost/examples/servlets/servlet/chat.ChatServlet - doesn't

How to call ChatServlet according to my config?

I understand that my question is stupid but I can't find the answer!
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess your url should be :
jsp/chat/chat
not
/jsp/chat/chat/ChatServlet
 
Julia Shreiber
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Leahcim wrote:i guess your url should be :
jsp/chat/chat
not
/jsp/chat/chat/ChatServlet



Thanks I tried it yesterday... and also now again...

HTTP Status 404 - /examples/servlets/servlet/jsp/chat/chat/
--------------------------------------------------------------------------------
type Status report
message /examples/servlets/servlet/jsp/chat/chat/
description The requested resource (/examples/servlets/servlet/jsp/chat/chat/) is not available.




 
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julia,
you should try using what Michael has suggested.
try this



hope this helps.
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julia,
you should try using what Michael has suggested.
try this



hope this helps.
 
Julia Shreiber
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

pravin shirke wrote:Hi Julia,
you should try using what Michael has suggested.
try this



hope this helps.



Thank you, great! It helps

This one worked:

http://localhost/examples/jsp/chat/chat

Thanks and thanks and thanks again!
 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's cool, you can mark it as resolved then
 
Julia Shreiber
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I don't see "Resolved" button here... Is it already marked?
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!