Deploying a simple servlet on Tomcat.
Date: 12/14/04
(Apache) Keywords: browser, html, xml, java, web
Edit: Thanks, solved.
Hi, I'm having problems deploying a very simple servlet on Tomcat 5.5. When I direct my browser to the expected URL, Tomcat just spits back a blank "Directory Listing for /" page, and I'm not seeing anything helpful in the logs.
I'm wondering if the problem is that I have not included any .html files in my webapp ... but I don't understand why I would need to, or what I would have to put in it.
Compiles fine.
Servlet Code:
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("");
out.println("See my first demo work!");
out.println("");
out.println("");
}
}
The URL I type into my browser is
http://localhost:8080/Hello. No dice :(
Web.xml config:
Hello v2
Hello Demo
Hello
HelloWorldExamplelet-class>
Hello
/Hello
As I understand it, this configuration should allow me to access my servlet by http://localhost:8080/Hello
.war layout:
demo/
WEB-INF/web.xml
WEB-INF/classes/HelloWorldExample.class
WEB-INF/classes/HelloWorldExample.java
I've read the tomcat docs and "Tomcat - The Definitive Guide" (O'Reilly). Many thanks if anyone could offer me some pointers.
-Phil
Source: http://www.livejournal.com/community/apache/14800.html