Tomacat and servelts
843841Mar 29 2004 — edited Mar 29 2004Hello everyone.
I just switched to web application desgin, I installed Tomcat and got it running, I have a simple servlet "HellowWorld" I want to run it from within an html form by clicking submit button, I don't want to write a deployment file or web.xml because I am still a small guy. I just want to manully create the directory structure for my project and copy the *.class, can some body kind of walk me to how I create a very simple directory structure and what I how I correct this html file to get the sevlet run:
my html file:
<HTML>
<HEAD>
<TITLE>
Servlet HTTP GET Example
</TITLE>
</HEAD>
<BODY>
<FORM
ACTION="http://localhost:8080/servlet/HTTPGetServlet"
METHOD="GET">
<P>Click the button to have the servlet send
an HTML document</P>
<INPUT TYPE="submit" VALUE="Get HTML Document">
</FORM>
</BODY>
</HTML>
my servlet class:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HTTPGetServlet extends HttpServlet {
public void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
{
PrintWriter output;
response.setContentType( "text/html" ); // content type
output = response.getWriter(); // get writer
// create and send HTML page to client
StringBuffer buf = new StringBuffer();
buf.append( "<HTML><HEAD><TITLE>\n" );
buf.append( "A Simple Servlet Example By Isam Abdelhameed\n" );
buf.append( "</TITLE></HEAD><BODY>\n" );
buf.append( "<H1>Welcome to Servlets By Isam Abdelhameed!</H1>\n" );
buf.append( "</BODY></HTML>" );
output.println( buf.toString() );
output.close(); // close PrintWriter stream
}
}
thank you very much, you don't know how valuable is your help