aspose file tools*
The moose likes Servlets and the fly likes simple problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "simple problem" Watch "simple problem" New topic
Author

simple problem

Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
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


Thanks & Regards<br />Sunesh Kumar Baachu
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
forgot to add this

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

bye
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Probably posting the web.xml would be a nice idea.
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
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
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Oct 17, 2005
Posts: 89
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 ...
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
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

Joined: Oct 17, 2005
Posts: 89
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Oct 17, 2005
Posts: 89
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"...
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Udhan Velayutham
Greenhorn

Joined: Mar 29, 2006
Posts: 4
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

Joined: Mar 29, 2006
Posts: 4
Hi Sunesh
can u gimme ur mail id such that i can send u a sample to code...
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
Hi Udhan,

Thanks for help yaar. my id is

suneshkumar@gmail.com

waiting for ur reply ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple problem
 
Similar Threads
getting error while running servlet in tomcat
Error 404: File not found: loadservlet
Need help
HTTP status 404 error from Tomcat
help needeed....