File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple problem

 
Sunesh Kumar
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably posting the web.xml would be a nice idea.
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ...
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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"...
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Udhan Velayutham
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Udhan,

Thanks for help yaar. my id is

suneshkumar@gmail.com

waiting for ur reply ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic