Tomcat Beginner problem

[nobr]Hi, I am a Beginner of learning Tomcat & JSP. According tutorial, I follow the code and found it can't work,

I place the BasicServlet.java into C:\jakarta-tomcat-5.0.28\webapps\ROOT\

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

publicclass BasicServletextends HttpServlet{

publicvoid init(ServletConfig config)

throws ServletException{

super.init(config);

}

publicvoid doGet(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException{

response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("<html>");

out.println("<head><title>BasicServlet</title></head>");

out.println("<body>");

out.println("Your request method was " + request.getMethod()

+"\n");

out.println("</body></html>");

out.close();

}

publicvoid doPost(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException{

response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("<html>");

out.println("<head><title>BasicServlet</title></head>");

out.println("<body>");

out.println("Your request method was " + request.getMethod()

+"\n");

out.println("</body></html>");

out.close();

}

public String getServletInfo(){

return"BasicServlet Information";

}

}

A html file create into C:\jakarta-tomcat-5.0.28\webapps\ROOT\BasicServlet.html

<HTML>

<HEAD>

<TITLE>

BasicServlet

</TITLE>

</HEAD>

<BODY>

<FORM

ACTION=http://localhost:8080/BasicServlet

METHOD=POST>

<BR><BR>

press Submit Query to launch servlet BasicServlet

<BR><BR>

<INPUT TYPE=submit>

<INPUT TYPE=reset>

</FORM>

</BODY>

</HTML>

When I browse the html file, and click "Submit Query", there come "error" display, What is the happen going on? Anyone can try me out, thank you.

Message was edited by:

jiong_rong[/nobr]

[3585 byte] By [jiong_ronga] at [2007-11-27 10:45:00]
# 1

Looks like you need the basic tutorial.

This is an excellent one. It has slightly different versions for the different versions of Tomcat.

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-5.5.html

http://www.coreservlets.com/Apache-Tomcat-Tutorial/Tomcat-5.0-and-4.0.html

Basically you are not deploying the servlet correctly.

You need to compile the servlet, put it in the WEB-INF/classes directory.

Probably you also need to put the servlet in a package.

Also you should probably add a mapping to web.xml for this servlet.

The tutorial covers all of those steps.

evnafetsa at 2007-7-28 20:10:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...