I'm new to Java servlets and stuff. I run Eclipse Luna SR2 (for Java EE) and configured my project to use tomcat 8 as a server (on Linux Mint 17.1, if it helps).
I created a new project from File -> New -> Dynamic Web Project.
While adding the tomcat 8 server I did not change any of the default params except specifying the tomcat root directory.
Then I imported the servlet-api.jar file (from tomcat/lib directory).
I have one class file in my project which does not have any errors. So when I run tomcat from within Eclipse I get The requested resource is not available.
. I know this is very common error and I'd be happy to give the required information.
Here is the class file -
package ch1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class serv1 {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>" +
"<body>" +
"<h1 align=center>HF\'s Chapter1 Servlet</h1>" +
"<br>" + today + "</body>" + "</html>");
}
}
This is the directory structure of my project -
.
|-- build
| `-- classes
| `-- ch1
| `-- serv1.class
|-- .classpath
|-- .project
|-- .settings
| |-- .jsdtscope
| |-- org.eclipse.jdt.core.prefs
| |-- org.eclipse.wst.common.component
| |-- org.eclipse.wst.common.project.facet.core.xml
| |-- org.eclipse.wst.jsdt.ui.superType.container
| `-- org.eclipse.wst.jsdt.ui.superType.name
|-- src
| `-- ch1
| `-- serv1.java
`-- WebContent
|-- META-INF
| `-- MANIFEST.MF
`-- WEB-INF
`-- lib
EDIT: Here's a screenshot -
Can anyone help me as to where I got it wrong?