You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Demetrios Sapounas <ds...@med2web.com> on 2001/08/28 01:34:37 UTC

Strange servlet behaviour -- HELP!

The following refer to Tomcat 3.2.3 Linux binary distribution obtained
from jakarta.apache.org

Disclaimer: I read a lot of configuration messages on the mailing lists,
but I either did not 
find what applies to my set-up or I am missing something very obvious.

I installed tomcat as stand-alone, running on port 8080, configured the
tomcat/conf files and 
tested the servlet-specific examples that came with the distribution. 
The observation was that 
they working fine.

The tomcat classpath is:

Using classpath:
/var/tomcat/lib/ant.jar:/var/tomcat/lib/jasper.jar:/var/tomcat/lib/parser.jar:
/var/tomcat/lib/servlet.jar:/var/tomcat/lib/webserver.jar:/var/tomcat/lib/xerces.jar:
/usr/java/jdk1.3.1/lib/tools.jar


So, still in stand-alone mode, I tried to set-up a place where I can
"test" some of my code.  I 
created that new place under tomcat/webapps/ and I called it helpdesk. 
The full structure is:

  tomcat/webapps/helpdesk
                    |----> /WEB-INF
                               |---> /classes

under classes I placed some *.java files and created the corresponding
*.class files.

The first example code is:


// HelloWorld Servlet
 
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
public class HelloWorld extends HttpServlet {
 
  public void doGet(HttpServletRequest request, HttpServletResponse
response)
                   throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body bgcolor=#FFFFFF>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("<b>This is DS ...</b>");
    out.println("</body>");
    out.println("</html>");
  }
}


when I access it as localhost:8080/helpdesk/servlet/HelloWorld it works
fine and displays the 
"Hello World!" message on the browser.


The second example is:



/* $Id: HelloWorldExample.java,v 1.2.4.1 2000/07/05 17:45:01 nacho Exp $
 *
 */
 
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
/**
 * The simplest possible servlet.
 *
 * @author James Duncan Davidson
 */
 
public class HelloWorldExample extends HttpServlet {
 
 
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        ResourceBundle rb =
           
ResourceBundle.getBundle("LocalStrings",request.getLocale());
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
 
        out.println("<html>");
        out.println("<head>");
 
            String title = rb.getString("helloworld.title");
 
            out.println("<title>" + title + "</title>");
        out.println("</head>");
        out.println("<body bgcolor=\"white\">");
        out.println("<body>");
 
        // note that all links are created to be relative. this
        // ensures that we can move the web application that this
        // servlet belongs to to a different place in the url
        // tree and not have any harmful side effects.
 
        // XXX
        // making these absolute till we work out the
        // addition of a PathInfo issue
 
            out.println("<a
href=\"/examples/servlets/helloworld.html\">");
        out.println("<img src=\"/examples/images/code.gif\" height=24 "
+
                    "width=24 align=right border=0 alt=\"view
code\"></a>");
        out.println("<a href=\"/examples/servlets/index.html\">");
        out.println("<img src=\"/examples/images/return.gif\" height=24
" +
                    "width=24 align=right border=0
alt=\"return\"></a>");
        out.println("<h1>" + title + "</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

I did not make any changes to this code.  It is exactly as it was
distributed with tomcat.
When I try to access is as
localhost:8080/helpdesk/servlet/HelloWorldExample I get the following 
(well documented on the newsgroups) error message.

Error: 500

Location: /helpdesk/servlet/HelloWorldExample

Internal Servlet Error:

java.util.MissingResourceException: Can't find bundle for base name
LocalStrings, locale en
        at
java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:712)
        at
java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:683)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:559)
        at HelloWorldExample.doGet(HelloWorldExample.java:24)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java)
        at org.apache.tomcat.core.Handler.service(Handler.java)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java)
        at 
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java)
        at java.lang.Thread.run(Thread.java:484)

I even created a web.xml file in tomcat/webapps/helpdesk/WEB-INF, which
is as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
 
<web-app>
<!-- HelloWorldExample servlet -->
    <servlet>
        <servlet-name>
            HelloWorldExample
        </servlet-name>
        <servlet-class>
            HelloWorldExample
        </servlet-class>
    </servlet>
    <servlet-mapping>
       <servlet-name>
            HelloWorldExample
        </servlet-name>
        <url-pattern>
            /HelloWorldExample
        </url-pattern>
   
</servlet-mapping>                                                                    

<!-- HelloWorld servlet -->
    <servlet>
         <servlet-name>
            HelloWorld
        </servlet-name>
        <servlet-class>
            HelloWorld
        </servlet-class>
    </servlet>
    <servlet-mapping>
       <servlet-name>
            HelloWorld
        </servlet-name>
        <url-pattern>
            /HelloWorld
        </url-pattern>
   
</servlet-mapping>                                                                    

</web-app>


Could someone please provide some help.  What am I missing in the
configuration?  The same example works fine, under the
localhost:8080/examples/servlet/RequestInfoExample URL!!!!!!

Thank you!

Demetrios
ds@med2web.com