• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

simple problem

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,

As i am not a beginner programmer having months of experience in coding i am facing a ver simple problem which i cant able to rectify.

i am using tomcat 5.0 i wrote a beginner HelloServlet like this

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class HelloServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

resp.setContentType("text/html");
PrintWriter out = resp.getWriter();

out.println("<HTML>");
out.println("<HEAD><TITLE>Have you seen this before?</TITLE></HEAD>");
out.println("<BODY><H1>Hello, World!</H1><H6>Again.</H6></BODY></HTML>");
}
}

placed in "tomcat5.0\webapps\root\web-inf\classes" and complied there itself

i am running like this
http://localhost:8080/servlet/HelloServlet

getting this error

HTTP Status 404 - /servlet/HelloServlet
type Status report
message /servlet/HelloServlet
description The requested resource (/servlet/HelloServlet) is not available.
Apache Tomcat/5.0.28

nore i restarted my tomcat server and also verified

what is this please help me
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
forgot to add this

i am not using any IDE pls.
just notepad
i am trying this for a sample application

bye
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably posting the web.xml would be a nice idea.
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi anupam,

using web.xml is nice idea and we have to do like that for a good practice.

But just i want to know what is happening whats the mistake i done is this o done anything wrong.

pls help with your ideas...
bye
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the looks of the URL that you're using to try to access your servlet, I'd guess that you're using a slightly out of date book or tutorial.

In the past, you could call servlets this way via the InvokerServlet.
That has been commented out of the Tomcat config scripts for the last few years. Your servlet will need to be mapped in your deployment descriptore (web.xml).

For more information, see:
http://faq.javaranch.com/view?InvokerServlet
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to use the InvokerServlet, which is why you can call the servlet without configuring it in web.xml, but the InvokerServlet is not enabled by default, you would have to configure Tomcat to allow this first.

Much better to configure the servlet correctly and not use the Ivoker, it is not a good thing to use.

Dave
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunesh Kumar:
Hi anupam,

using web.xml is nice idea and we have to do like that for a good practice.

But just i want to know what is happening whats the mistake i done is this o done anything wrong.



The mistake is that you're trying to use a feature that is no longer present.
The explicit mapping of servlets is no longer just a best practice. It's "how servlets are deployed".
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ben,

Thanks Ben . I dont know it has been eliminated just i saw the Url from the core servlets and JSP by Marty Hall and Blary Brown

Ok thanks to inform that this way is eliminated.
can u suggest any latest tutorial on the web for the JSP and servlets.

bye ...
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Visit the following URL, It has some ebook for jsp & servlets.
Ebook needs registration but free

bye for now
sat
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Satish,

its not working my dear friend. Could you please send me again the URL i am curious to learn perfectly jsp and servlets.

Bye..
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe "Core Servlets" has been updated and is in it's 2nd Edition now.

If you want a simple "Hello, World" servlet example, there is one on my site.
http://simple.souther.us
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ben...


Sorry for late response...

I am very much thankful to you for your site which had examples. i am very pleased to see this site.

and the link "http://faq.javaranch.com/view?InvokerServlet" is simply excellent Ben, thanks for this.

Another thing just i want to notify that
i am using

CoreServlets and JavaServerPages
Volume 1:Coretechnologies
Second Edition
only

in this book only i saw that urls any way thanks for notifying me..But i am suffereing with another problem as this book is not updated in future i may get any errors like this...pls can u guide me

Waiting for ur reply "Ben"...
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sunesh, when that version of core servlets book was written the examples used a previous version of tomcat. You eithr need to access the servlets as the previous posted have mentioned, get a more updated book, or just download the version of tomcat that book recommended, which I believe is version 3.1 or so.

BTW, that is a very good bok to learn from too.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sunesh,
Go thru this link...
Me to face teh same issue ..Its resolved now by following the idea int eh forum...

http://forum.java.sun.com/thread.jspa?threadID=720685
 
Udhan Velayutham
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sunesh
can u gimme ur mail id such that i can send u a sample to code...
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Udhan,

Thanks for help yaar. my id is

suneshkumar@gmail.com

waiting for ur reply ...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic