[404] Resource Not Found Error [message #676618] |
Sun, 05 June 2011 18:01 |
No real name Messages: 8 Registered: November 2010 Location: Boston, MA |
Junior Member |
|
|
Hello,
NOTE: I have another Dynamic Web Project runnable on the same Tomcat 7 server in the same instance of Eclipse Helios in the same workspace.
I'm running Tomcat7 inside of Eclipse Helios on top of Ubuntu Lucid Lynx. I have successfully started Tomcat7 inside of the IDE before invoking the following URL from the browser bar in FireFox,
http:--localhost:8080/HearingImpaired/InvokingTest.do
The name of my Dynamic Web Project is HearingImpaired. The name of the Servlet called for in the Deployment Descriptor is /InvokingTest.do
Although this should not make any difference, Eclipse Helios - Tomcat7 - Ubuntu are all running in an Oracle VirtualBox on top of Windows 7 64-bit Professional.
I have been able to create a standalone project outside of Eclipse Helios in
/var/lib/tomcat7/webapps/HearingImpaired, and I have been able to successfully launch my web application. After successfully launching my web app, I deleted /HearingImpaired from /var/lib/tomcat7/webapps/.
I don't believe that there are any errors in my web.xml file. I have attached the file for your examination. I used the web.xml file supplied with Tomcat7 as a starter file. All the files in my application build without any errors in Eclipse Helios.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http:--www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http:--www.w3.org/2001/XMLSchema-instance" xmlns="http:--java.sun.com/xml/ns/javaee" xmlns:web="http:--java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http:--java.sun.com/xml/ns/javaee http:--java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
<servlet>
<servlet-name>Tester</servlet-name>
<servlet-class>com.example.ListenerTester</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Tester</servlet-name>
<url-pattern>/InvokingTest.do</url-pattern>
</servlet-mapping>
<context-param>
<param-name>breed</param-name>
<param-value>Great Dane</param-value>
</context-param>
<listener>
<listener-class>com.example.MyServletContextListener</listener-class>
</listener>
</web-app>
package com.example;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ListenerTester extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("This is my second attempt<br>");
out.println("<br>");
Dog dog = (Dog)this.getServletContext().getAttribute("dog");
out.println("The Dog's breed is" + dog.getBreed());
}
}
package com.example;
public class Dog {
private String breed;
public Dog(String breed) {
this.breed = breed;
}
public String getBreed() {
return breed;
}
}
package com.example;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
/**
* Application Lifecycle Listener implementation class MyServletContextListener
*
*/
@WebListener
public class MyServletContextListener implements ServletContextListener {
/**
* Default constructor.
*/
public MyServletContextListener() {
// TODO Auto-generated constructor stub
}
/**
* @see ServletContextListener#contextInitialized(ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent event) {
ServletContext sc = event.getServletContext();
String dogBreed = sc.getInitParameter("breed");
Dog d = new Dog(dogBreed);
sc.setAttribute("dog", d);
}
/**
* @see ServletContextListener#contextDestroyed(ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
}
Any idea why I'm getting a Resource Not Found 404 error in my Browser?
Any help will be appreciated.
Thanks,
Harry
[Updated on: Sun, 05 June 2011 19:59] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.05430 seconds