File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat 7.0, Eclipse Juno, simple form processing servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 7.0, Eclipse Juno, simple form processing servlet" Watch "Tomcat 7.0, Eclipse Juno, simple form processing servlet" New topic

Tomcat 7.0, Eclipse Juno, simple form processing servlet

John Bordenet

Joined: Nov 16, 2008
Posts: 2
Started with a simple issue that Tomcat wouldn't recognize my servlet. I was able to get to the the initial jsp form.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<form action="VisitServlet" method="post">
Steward Visit Record
Steward: <input type="text" name="steward" size="20">

Last Name: <input type="text" name="lastName" size="20">

First Name: <input type="text" name="firstName" size="20">


Wrote a simple servlet that had nothing to do with the form so I could isolate my issues.
package serve;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.annotation.*;

* Servlet implementation class VisitServlet
public class VisitServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n" +
"<HTML>\n" +
"<BODY>\n" +
"<H1>Hello WWW</H1>\n" +

Since this servlet used annotations, the web.xml file was unnecessary, but I included it anyway.
<?xml version="1.0" encoding="UTF-8"?>

Since I was dealing with "requested resource not found" issue, I visited the Tomcat forum here and changed the server location as suggested. This resulted in a cascade of other issues. After I tried to change it back it back to use the workspace metadata, I continued to receive additional server messages such as
Oct 17, 2012 9:30:21 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Program Files (x86)\Apache\Tomcat 7.0\ROOT\visitKUUC does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(
at org.apache.catalina.core.StandardContext.resourcesStart(
at org.apache.catalina.core.StandardContext.startInternal(
at org.apache.catalina.util.LifecycleBase.start(
at org.apache.catalina.core.ContainerBase$
at org.apache.catalina.core.ContainerBase$
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

Oct 17, 2012 9:30:21 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error in resourceStart()

To make matters worse, the Tomcat logs are not being updated. (This may be because I changed the installation of Tomcat to a new location. Eclipse can find this old directory even though it has been deleted.)
I would appreciate any help to make progress.

John Bordenet

John Bordenet

Joined: Nov 16, 2008
Posts: 2
You ignore the last section where I changed the server location. I was able to revert it back to the default location and thos messages are resolved.
I agree. Here's the link:
subject: Tomcat 7.0, Eclipse Juno, simple form processing servlet
jQuery in Action, 3rd edition