tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Callo <francisca...@yahoo.com>
Subject Re: newbie: Installing Servlets
Date Mon, 18 Jun 2001 17:06:15 GMT
Hi,
if you have a servlet named "HelloWorld"i believe you
have to put your classes on
"webapps/examples/WEB-INF/classes/" and access it with
URL
"http://localhost:8080/examples/servlet/HelloWorld"
Let me know if it works. ;)

GUD LUK
Francis

--- LeRoi <leroi@blueyonder.co.uk> wrote:
> Hello!
> 
> Now that I have Tomcat up and running, it's time
> that I starting doing some
> real work.  Following a simple example in the book
> I'm using it says that
> servlets are installed in the subdirectory
> "webapps\WEB-INF\servlets".  I
> put my class there (under "examples" directory of
> Tomcat) and shut down
> Tomcat and re-started it.  Below is the code for
> textbook example:
> 
> // Fig. 19.5:  HTTPGetServlet.java
> // Creating and sending a page to the client
> 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\n");
> 		buf.append("</TITLE></HEAD><BODY>\n");
> 		buf.append("<H1>Welcome to Servlets!</H1>\n");
> 		buf.append("</BODY></HTML>");
> 		output.println(buf.toString());
> 		output.close();  // close PrintWriter stream
> 	}
> }
> 
> <!-- Fig. 19.6: HTTPGetServlet.html -->
> <HTML>
> 	<HEAD>
> 		<TITLE>
> 			Servlet HTTP GET Example
> 		</TITLE>
> 	</HEAD>
> 	<BODY>
> 		<FORM
> 		
>
ACTION="http://localhost:8080/servlets/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>
> 
> Well, it didn't work.  My question is, in order to
> install this simple
> servlet does that mean I have to go through all the
> steps as given in the
> documentation for "Developing Applications with
> Tomcat"?
> 
> Cheers and many thanx in advance,
> LeRoi
> 
> 


__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/

Mime
View raw message