Deploying a simple servlet on Tomcat.
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:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
<web-app>
<display-name>Hello v2</display-name>
<description>Hello Demo</description>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorldExample</serv let-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
</web-app>
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
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:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
<web-app>
<display-name>Hello v2</display-name>
<description>Hello Demo</description>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorldExample</serv
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
</web-app>
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
