aspose file tools*
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
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
Author

Tomcat 7.0, Eclipse Juno, simple form processing servlet

John Bordenet
Greenhorn

Joined: Nov 16, 2008
Posts: 2
Hello.
Started with a simple issue that Tomcat wouldn't recognize my servlet. I was able to get to the the initial jsp form.
record.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<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.
VisitServlet.java:
package serve;


import java.io.IOException;
import java.io.*;
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
*/
@WebServlet("/hello.html")
public class VisitServlet extends HttpServlet {
private static final long serialVersionUID = 1L;


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

}
Since this servlet used annotations, the web.xml file was unnecessary, but I included it anyway.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>VisitSerlvet</servlet-name>
<servlet-class>visitKUUC.serve.VisitServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VisitServlet</servlet-name>
<url-pattern>/hello.html</url-pattern>
</servlet-mapping>
</web-app>

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(FileDirContext.java:138)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4906)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5086)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown 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
Greenhorn

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tomcat 7.0, Eclipse Juno, simple form processing servlet