I think I messed-up with explaining what I’m trying to do here…
I have the following .java file located in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\webdev\WEB-INF\classes\sample:
package sample;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<head><title>Hello World!</title></head>");
out.println("<body>");
out.println("<h1>Hello World! Dude!</h1>");
out.println("</body></html>");
}
}
The Tomcat XML file being used in this is the following and found in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\webdev\WEB-INF:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<description>
AppDev Class Example
</description>
<display-name>Hello World! Dude!</display-name>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>sample.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
In the Apache Tomcat 7 Properties window (the “Configure Tomcat” tool that’s accessed from the Start / Programs / Apache Tomcat 7.0 directory), “Java Classpath” is set to: C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\ omcat-juli.jar
Unfortunately, my HelloWorld Java app wouldn’t compile correctly unless I used the j2ee.jar from the Sun directory: C:\Sun\SDK\lib
I’ve been trying to view my final .class file (after compiling it with javac) by going into Firefox and accessing the URL “[B]http://localhost:8888/webdev/HelloWorld[/B]” (I’ve had to set it to listen to 8888 due to other servers running on the system).
Inside the about:plugins with Firefox 3.6, there’s information about “Java™ Platform SE 6 U25” and “Java Deployment Toolkit 6.0.250.6”. They’re both enabled.
Whenever I try to access this final .class file through the browser (I refer to it as an applet–which is probably wrong) I get nothing but the markup within that Java file. However, when I try to access it inside of IE8, everything comes out great.
Sorry for any confusion. What’s going on here? Why doesn’t this work in Firefox?