Just can't run HELLOWORLD servlet on Tomcat!

Hi there, I worked with servlets all summer long and now I'm getting back to build one, and I'm totally confused... My problem's there :
I try to run a simple HelloWorld servlet on Tomcat 4.1, and I get a 404 Error - Not found
Well, here's the structure of my web application, contained in simpleservlet.war :
WEB-APP
-web.xml
-CLASSES
-servlet.class
-LIB
-servlet.jar
Here's now the content of the web.xml file :
<web-app>
     <servlet>
          <servlet-name>serv</servlet-name>
          <servlet-class>servlet</servlet-class>
     </servlet>
     <servlet-mapping>
          <servlet-name>serv</servlet-name>
          <url-pattern>/test</url-pattern>
     </servlet-mapping>
</web-app>
AND FINALLY here's how I invoke my servlet, I TRIED :
http://localhost:1977/servlet/test
AND ALSO
http://localhost:1977/test
AND BANG, I GET "ERROR 404 - NOT FOUND"
A little help would be appreciated A LOT, well it's not supposed to be a hard problem... and by the way, I'm using port :1977, the problem's not there though.
regards, Pierre

Hi,
First try http://localhost:1977 and see if you are getting Tomcat. As you said, this is not a problem. So, you should get the index.html of the Tomcat. Now, click on the one of the example. From the Address Bar, you will know the path of this example. Try putting your page at that location and then run.
This should work.
-- Ashish.

Similar Messages

  • How can I run a servlet with tomcat

    I'm a new learner in servlet,I recently write a servlet program,when I compile it,the compiler throws the error
    "package javax.servlet.http does not exist",I have put the servlet.jar(which exist in d:\tomcat\bin directory) file into the classpath directory;my servlet source files are in D:\tomcat\webapps\mywork\web-inf\classes\com\stardeveloper\servlets;
    "com.stardeveloper.servlets" is the package for my servlet source files,so I have write the sentence "package com.stardeveloper.servlets;" in my servlet source file.
    I don't know how to resolve this problem.can you give me a help?

    servlet.jar doesn't exist in the folder you mentioned, but rather, in C:\tomcat40\common\lib, so this should be included in your classpath, the other thing you should care about is how you compiled your servlets, so that the package statement match the hirarchy of the file.
    regards

  • How to run a servlet in tomcat

    how i can run a servlet in tomcat?

    how i can run a servlet in tomcat?Don't try to do that yet; in your other thread you have shown that your are
    not capable yet of setting up a proper development environment.
    Take my advice, you can't walk or run yet so start with the basics.
    kind regards,
    Jos

  • How to run a servlet in tomcat 5.5

    Hi,iam new to servlets,please help me regarding running a servlet in tomcat 5.5,
    I just want an example servlet to run first,
    the below is the code for the same :-
    //ExampleServlet.java
    package sig;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ExampleServlet extends HttpServlet {
         public void init(ServletConfig config) throws ServletException{
              super.init(config);
         public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
              PrintWriter out = res.getWriter();
              out.println("<HTML>");
              out.println("<BODY>");
              out.println("<p>Hello World</p>");
              out.println("</BODY>");
              out.println("</HTML>");
    I have created a new folder named "SignatureServlet" under the "webapps" folder of tomcat and have created a "WEB-1NF" folder under it,
    again i have kept my "ExampleServlet.class" inside the "WEB-1NF->classes" folder and the entries for my servlet in the "web.xml" file are:-
    <servlet>
    <servlet-name>ExampleServlet</servlet-name>
    <servlet-class>ExampleServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ExampleServlet</servlet-name>
    <url-pattern>/ExampleServlet</url-pattern>
    </servlet-mapping>
    still when iam trying to access the servlet using "http://localhost:8080/ExampleServlet/"
    iam getting a HTTP:404 error
    The requested resource () is not available.,
    please help

    You better ask this on a Tomcat forum...
    Timo

  • How to run a servlet in tomcat 5.0.

    Hi all,
    how to run a servlet in tomcat 5.0
    please tell me the entire procedure....(directory structure)
    step by step....

    hi :-)
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
    or
    http://www.google.com.ph/search?hl=en&q=java+servlet+tutorial&btnG=Google+Search&meta=
    regards,

  • PLEASE HELP Can't run my servlet url-pattern with Tomcat

    Hi I'm trying to run servlet with Tomcat.
    I have don the servlet with tomcat ide abd its runnig ok with Forte with the internal Tomcat
    When I'm runing it with external Tomacat its not running at the url that I have given in the web.xml
    web.xml file:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>ClaimsServlet</servlet-name>
    <servlet-class>ild.claims.ClaimsServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>ild.claims.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ClaimsServlet</servlet-name>
    <url-pattern>/ild/claims/claims</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/ild/claims/LoginServlet</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    90
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>
    default.jsp
    </welcome-file>
    <welcome-file>
    index.html
    </welcome-file>
    <welcome-file>
    index.htm
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if I runnig the url: /ild/servlet/ild/claims/ClaimsServlet
    its running
    but //ild/claims/claims
    I got: The requested resource (/claims/claims) is not available.
    Thanks for help
    Snir

    Do you have to use <url-pattern>/ild/claims/claims</url-pattern>
    or you can use <url-pattern>/claims</url-pattern> ?

  • Cannot run a servlet using Tomcat. Urgent

    I have a webapplication which uses some jsp's and servlets. The jsp pages work fine when I use
    http://hostname:8080/MyWebapp/Filename.jsp
    However, when I developed a java servlet and put the class file in WEB-INF/classes directory of my web application and tried to access it.
    I got a resource not found error.
    The strange thing is that when I put the file in the web-inf/classes folder of examples webapplication (which comes with Tomcat) I am able to run the servlet using
    http://hostname:8080/examples/servlet/Class file
    I am not sure what is wrong.
    Can someone help me.
    Thanks in advance
    Vamsi.

    It's predictable. The Servlet and JSP specifications mandate that you cannot directly access resources under WEB-INF directory. You have to set up servlet mapping configuration in your web.xml to specify how to access the resources, both Servlet and JSP, there.
    When you copied your files in a demo webapp of Tomcat, the web.xml of the demo app already set up the mapping like following for you. So you could use http://hostname:8080/examples/servlet/Class to visit the servlet.
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    The default setting since Tomcat 4.1 turned off servlet invoker in web.xml under conf directory. You can uncomment the above lines in this file to turn it on. Then you are able to visit your servlet without <servlet-mapping> configured using the following syntax,
    http://hostname:8080/<your_app_name>/servlet/<your_servlet_name>

  • How to run a servlet in Tomcat 5.0 server

    HI Everybody,
    I want to know how to run the servlet file on my tomcat 5.0 server. that is where to place a class file and deployment details.
    Thanks In ADVANCE

    Sourav_cs wrote:
    I am a biginner to start servlet i get confusion to configure servlet in tomcat 5 where it should be saved in tomcat directory and how to execute that as first timeHi,
    goto
    tomcat 5.0\webappsnow create a folder here. this is your webapplication project name. Let's suppose it as "TestApp"
    inside this create directories as follows :
    TestApp
            |
            |-----JSP/htmls( if you have any )
            |
            |-----WEB-INF(File Folder)
                       |
                       |-----web.xml
                       |-----lib ( Directory. place all the .jar files which are required for this project(if any) )
                       |-----classes ( .class files. )[all of your java code should be placed here.](servlets / beans/ pojo )this is the general Directory structure of a web application. now you've to place the compiled .class file of your servlet in the "TestApp\WEB-INF\classes" directory. make sure that you've configured the servlet in Deploment Desctiptor, i.e, web.xml.
    now start the server and type the url like : "http://localhost:8080/TestApp/TestServlet"
    the port no. 8080 is the default port no. of tomcat. you have to give your port no. if u've modified it. and TestServlet is the <url-pattern> of your servlet.
    go through some tutorials .. then you can easily know that
    Diablo

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • Running HelloWorld Servlet--Tomcat 4.1

    Dear Sir,
    With most humble submission I would like to inform you that I have recently downloaded Tomcat 4.1 from http://jakarta.apache.org/ and installed it on Windows 98. I am using jdk1.3
    I am an amateur for Java Servlets. I am following the instructions given in the book "Java Servlet Programming" by O'reilly and according to this book I have to store my class files(I tried with HelloWorld.class) in the dir server_root/webapps/root/web-inf/classes dir. but when i called it from microsoft internet explorer 5.0(the browser i am using currently) using the URL http://localhost:8080/servlet/HelloWorld
    I get the 404 error.
    I also tried to call a static file (.html) by storing it in the dir server_root/webapps/root(according to the book) and i get the proper output but not in case of .class file. Even the example codes provided with the server do not run.
    Please help me to fix out my problem.
    Thanking you in anticipation,
    Yours sincerely
    roopesh

    Hi:
    1)You need set classpath
    2) do you open your Tomcat?
    Thank

  • Can not run helloworld.xsql on Netscape. Enterprise Server 4.0 SP4?

    We are running //...//oracle.xml.xsql.XSQLServlet/helloworld.xsql on Netscape. Enterprise Server 4.0 SP4 on UNIX and getting the following message
    XSQL-003: Failed to find 'XSQLConnections.xml' file in server CLASSPATH.
    XSQL-004: Could not acquire a database connection named: demo
    XSQL-007: Cannot acquire a database connection to process page.
    We have tried to put XSQLConfig.xml in every where that the Server suppose to find, but returned with the same error message. We don't know what we can do next. Can any of you give us some suggestion? Besides, we also have following questions:
    1. How do you treat XSQLConfig.xml inside of your source code? Which path does it search?
    2. Is the file XSQLConfig.xml all lower case or case mixed inside of your code? Because when we extract downloaded file on UNIX machine, it returns with xsqlconfig.xml, but on WINNT, it was XSQLConfig.xml. Which one is right? However, in UNIX even we chang it to XSQLConfig.xml, it still does work.
    We are really in dead-end, please help.
    Julie Zhu

    How did you setup the *.xsql mapping to the
    oracle.xml.xsql.XSQLServlet servlet ?
    I don4t know how to do this with Netscape
    Enterprise Server.
    Thanks for your help!
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Julie Zhu ([email protected]):
    We are running //...//oracle.xml.xsql.XSQLServlet/helloworld.xsql on Netscape. Enterprise Server 4.0 SP4 on UNIX and getting the following message
    XSQL-003: Failed to find 'XSQLConnections.xml' file in server CLASSPATH.
    XSQL-004: Could not acquire a database connection named: demo
    XSQL-007: Cannot acquire a database connection to process page.
    We have tried to put XSQLConfig.xml in every where that the Server suppose to find, but returned with the same error message. We don't know what we can do next. Can any of you give us some suggestion? Besides, we also have following questions:
    1. How do you treat XSQLConfig.xml inside of your source code? Which path does it search?
    2. Is the file XSQLConfig.xml all lower case or case mixed inside of your code? Because when we extract downloaded file on UNIX machine, it returns with xsqlconfig.xml, but on WINNT, it was XSQLConfig.xml. Which one is right? However, in UNIX even we chang it to XSQLConfig.xml, it still does work.
    We are really in dead-end, please help.
    Julie Zhu<HR></BLOCKQUOTE>
    null

  • Can't run helloworld of Google App Engine (python 2.7)

    I looked and searched for the bug and found the post. -> See comment 29
    But, it seems that it's still not fixed in google-appengine 1.6.4 for python 2.7.
    The exact error is: (Trying to run the helloworld given in docs)
    WARNING 2012-04-06 23:26:00,928 py_zipimport.py:139] Can't open zipfile /usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info: IOError: [Errno 13] file not accessible: '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info'
    Full terminal output:
    shadyabhi@MBP-archlinux ~/codes/gae $ dev_appserver.py helloworld/
    INFO 2012-04-06 23:25:55,030 appengine_rpc.py:160] Server: appengine.google.com
    INFO 2012-04-06 23:25:55,034 appcfg.py:582] Checking for updates to the SDK.
    INFO 2012-04-06 23:25:56,709 appcfg.py:616] This SDK release is newer than the advertised release.
    WARNING 2012-04-06 23:25:56,710 datastore_file_stub.py:513] Could not read datastore data from /tmp/dev_appserver.datastore
    INFO 2012-04-06 23:25:56,773 dev_appserver_multiprocess.py:647] Running application dev~helloworld on port 8080: http://localhost:8080
    INFO 2012-04-06 23:25:56,774 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin
    WARNING 2012-04-06 23:26:00,928 py_zipimport.py:139] Can't open zipfile /usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info: IOError: [Errno 13] file not accessible: '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info'
    ERROR 2012-04-06 23:26:01,101 wsgi.py:189]
    Traceback (most recent call last):
    File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
    File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
    ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app
    INFO 2012-04-06 23:26:01,110 dev_appserver.py:2884] "GET / HTTP/1.1" 500 -
    ERROR 2012-04-06 23:26:01,479 wsgi.py:189]
    Traceback (most recent call last):
    File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
    File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
    ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app
    INFO 2012-04-06 23:26:01,486 dev_appserver.py:2884] "GET /favicon.ico HTTP/1.1" 500 -
    Any kind of help would be highly appreciated.
    Last edited by shadyabhi (2012-04-07 15:46:54)

    If you're using python2.7 libraries there's an error with the tutorial
    This line is incorrect:
    application = webapp2.WSGIApplication([('/', MainPage)], debug=True)
    The correct line should be:
    app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
    If it is asking for an "app" attribute, your code helloworld must have this attribute.
    See http://stackoverflow.com/questions/1005 … python-2-7

  • Can i run a servlet without a web.xml file for servlet mapping?

    Hello everyone.
    The code i want to run compiles and everythink looks ok.
    It produces the .class file.
    I run Tomcat 4.1 and i build my Web site with Dreamweaver.
    I have a form in a page and i want to send the data upon form completion to a database i already have build with MySql.
    The database is up and running and the server is set-up ok.
    I have changed the port in Tomcat to run on port 80.
    The directory i have my site is
    Tomcat41\webapps\ROOT\se
    and the directory where i keep the servlet class is
    Tomcat41\webapps\ROOT\se\WEB-INF\servlet
    I have a web.xml file to map the servlet and placed it in
    Tomcat41\webapps\ROOT\se\WEB-INF
    In the Form action i write action:"/servlets/Classes/GroupRegistration"
    and I RECEIVE AN 404 ERROR FROM APACHE.
    Somethink is wrong .
    The following is the code from the GroupRegistration.java file
    and follws the web.xml file.
    Please Help.
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class GroupRegistration extends HttpServlet
    Connection con;
    public void doPost (HttpServletRequest req, HttpServletResponse res)
                             throws ServletException, java.io.IOException
         handleForm(req, res);
    public void init() throws ServletException {
         try{
         /* Loading the driver for the database */
         Class.forName("com.mysql.jdbc.Driver");
         Connection Con = DriverManager.getConnection("jdbc:mysql://localhost/se?user=luser&password=");
         catch (ClassNotFoundException e) {
         throw new UnavailableException("Couldn't load JdbcOdbcDriver");
         catch (SQLException e) {
         throw new UnavailableException("Couldn't get db connection");
         private void handleForm(HttpServletRequest req, HttpServletResponse res)
         throws ServletException {
         //ServletOutputStream out = res.OutputStream();
         //res.setContentType("text/html");
         //Extract the form Data Here
         String group = req.getParameter("GroupNo");
         String Name1 = req.getParameter("Name1");
         String LoginID1 = req.getParameter("LoginID1");
         String Name2 = req.getParameter("Name2");
         String LoginID2 = req.getParameter("LoginID2");
         String Name3 = req.getParameter("Name3");
         String LoginID3 = req.getParameter("LoginID3");
         String Name4 = req.getParameter("Name4");
         String LoginID4 = req.getParameter("LoginID4");
         String URL = req.getParameter("URL");
         String Title2 = req.getParameter("Title2");
         String date = req.getParameter("date");
         String INSERT = "INSERT INTO registration (groupno, name1, loginid1, name2, loginid2, name3, loginid3, name4, loginid4, url, topic, date) VALUES (" + group + "," + Name1 + "," + LoginID2 + "," + Name2 + "," + LoginID2 + "," + Name3 + "," + LoginID3 + "," + Name4 + "," + LoginID4 + "," + URL + "," + Title2 + "," + date + ")";
         PreparedStatement pstmt = null;
         try{
         pstmt = con.prepareStatement(INSERT);
         pstmt.executeUpdate();
         catch (SQLException e) {
         throw new ServletException(e);
         finally {
         try {
         if (pstmt != null)pstmt.close();
         catch (SQLException ignored){
    The web.xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com.xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <servlet>
    <servlet-name>GroupRegistration</servlet-name>
    <servlet-class>GroupRegistration</servlet-class>
    </servlet>
    <servlet-maping>
    <servlet-name>GroupRegistration</servlet-name>
    <url-pattern>/myGroupRegistration</url-patern>
    </servlet-mapping>
    </web-app>
    I apreciate your time.
    Thanks for any help.

    and the directory where i keep the servlet class is
    Tomcat41\webapps\ROOT\se\WEB-INF\servletOthers have pointed out that "servlet" should be "classes", but there is another mistake that hasn't been spotted. If you want your servlet to appear in the root context, you should use:
    Tomcat41\webapps\ROOT\WEB-INF\classes
    If you want your servlet to appear under the /se context, then you should use:
    Tomcat41\webapps\se\WEB-INF\classes
    and also, in the latter case, your form action should be /se/myGroupRegistration.

  • Can we run a servlet application on mobile?

    Hi,
    I'm new to servlets and mobile web as well.
    I want to design an application which user can access through mobile and as well as dekstop.
    1.) Can we access a web application designed through servlets and JSP via mobile device (e.g, PDA and mobile handphone)?
    2.) Do we require to create two "copies" of an application, one for computer based and one for mobile device based?
    3) Do we follow some other architecture to design for a mobile enabled web site?
    Please share some examples or papers.
    Thanks in Advance

    Servlet and other stuff were developed for a purpose of viewing web pages on any devices etc. Problem with javascript for example is that it is client-runnable. On the other hand, servlets and JSP run on a server. Users (clients) only get a HTML and nothing more (ok maybe XML and other formats), but they don't run code.
    That means that you can view a web app on any device that supports HTML. Of course formating can be set for each device (PC, PDA, mobile, etc).
    "U want to say that we can access an web application developed using JSP and servlets for the use of dekstops on Mobile or PDA also.": YES
    "Or we have to do the WAP programming for the same.": WAP programming is dead for a few years now :)

  • Problem running simple servlet on tomcat 4.0

    hi,
    i have setup tomcat4.0 on the server and i am trying to run a simple servlet but it is not working. here is what i have done:
    1. setting the CATALINA_HOME variable to the directory where tomcat is installed
    2. setting the classpath variable to servlet.jar
    3. i am putting the .class fille in tomcat-home-directory/webapps/ROOTS/WEB-INF/classes
    4. i am giving the url as http://localhost:8080/servlet/HelloServlet.class
    but error is given...could you please tell where could i have probably made a mistake
    regards
    preeti

    hi tnguyen1973
    now my servlets are running on the server provided they are kept under /examples/WEB-INF/classes. But now i have my own folder at the same level of examples called Lm which also has WEB-INF/classes. but if i put my servlets here it is giving exception.hope u got me. please, tell me where should i make necessary modifications to get the servlets run from my own folder instead of examples
    thank u

Maybe you are looking for

  • Cannot delete playlist from Walkman

    Hi - Just got a Z1 compact and went to put my micro sd card from my old phone into the sony. Everything is fine except i cannot delete playlists from the My Playlists section of Walkman. The playlists have no content in them, i can't add content to t

  • Table & field required

    Hi,      Where do I will find quantity & requirement date for Purchase Order, purchase Requisition& planned Order. ( I mean Table & field for PO, PR & Planned Order for qty & requirment date). For example In table EBAN For PR & feild is MENGE PR qty

  • Pages on iMac 2010

    Just updated to mavericks; now can't open certain files in pages on my Mac, cause have to upgrade to version 5.0  = €17,99 This was told to me by Apple support, by email . It's just unacceptable !! Apple has to give me the possibility to use my docs

  • Reader XI annoying pop up

    How do I get rid of the annoying pop up I get every time I open a pdf file with Reader XI?

  • Imovie Crashes when copying project/event to external

    If I try and copy the project/ and event from within Imovie, Imovie crashes. If I copy them separately to external, it works. I'd like to do it together, as this way is too slow! This only happens on some projects, other copy without a hitch. I will