• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
I don't see "Resolved" button here... Is it already marked?
 
The City calls upon her steadfast protectors. Now for a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic