servlet beginner confused - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

servlet beginner confused

anarelleanarelle Posts: 2Member
I need to call a servlet from an HTML file, but I can't get my servlet to work outside the Eclipse IDE. Something must be wrong with my paths, but I don't know what.
I'm using Tomcat 7.0.

This is my servlet class:
package myapp;
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
StringBuffer sb = new StringBuffer();

Hello World!


I also have this web.xml file:



And my HTML file has a simple form like this:

Then, in my C:Program FilesApache Software FoundationTomcat 7.0webapps folder I created a "test" folder where I placed my index.html file and a WEB-INF folder with the web.xml file and a sub-folder called "classes", where I placed and HelloServlet.class.
I also set environment variables in my windows 7 system: CATALINA_HOME with value C:Program FilesApache Software FoundationTomcat 7.0 and CLASSPATH with value %CLASSPATH%;%CATALINA_HOME%commonlibservlet-api.jar;.

With all of this, I start tomcat, open index.html and click on the submit button. All I get is a "Firefox can't find the file at /C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/test/HelloServlet" error message.
What kind of newbie mistake am I making?

Sign In or Register to comment.