Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2006, 06:26 AM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to discuss
Default servlet problem


hi,

I am using Tomcat 5.5 server, jdk1.5.0_06 version.
Operating System is: Windows XP

i have two files:

Hello.htm
Hello.java (servlet file)

I have compiled Hello.java and it's compiled perfectly.

now i have to run this.
------------------------------------------------------------------
My File name is: Hello.htm

<html>

   <head><title> Introduction </title></head>

   <body>

      <form method=get action="/temp/Hello">

         If you don't mind me asking, what is your name?

         <input type=text name="name"><p>

         <input type=submit>

      </form>

   </body>

</html>
------------------------------------------------------------------

My File name is: Hello.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Hello extends HttpServlet{

   public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {


      res.setContentType("text/html");

      PrintWriter out = res.getWriter();

      String name = req.getParameter("name");

      out.println("<HTML>");
      out.println("<HEAD><TITLE> Hello, " + name + " </TITLE></HEAD>");
      out.println("<BODY>");
      out.println(" Hello, " + name);
      out.println("</BODY>");
      out.println("</HTML>");
   }

   public String getServletInfo(){

      return "A servlet that knows the name of the person to whom it's " +
              "saying hello";

   }
}
---------------------------------------------------------------------

Now problem is where i have to put these three files?

I have put these three files in: C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF\classes

but it doesn't work.. with http://localhost:8080/servlet-examples/servlet/Hello

but doesn't work...

i could not reach Hello.htm file.

how to do these...? request for tips.

thanks



Thanks
 
Old August 29th, 2006, 10:03 AM
Registered User
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elishae
Default

Modify your Hello.htm to use
Code:
<form method=get action="/servlet-examples/Hello">
Put your hello.htm file here.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples

put yout Hello.class here.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF\classes

You need not put Hello.java in webapp.
*Remember to restart tomcat and try accessing the url
http://localhost:8080/servlet-examples/Hello.htm








Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with servlet developer.ibm Servlets 1 September 12th, 2007 11:22 PM
Servlet Problem cziaul Servlets 2 April 28th, 2007 09:39 AM
My servlet problem saeed Servlets 1 April 10th, 2007 07:12 AM
servlet Problem discuss Servlets 3 February 6th, 2007 02:06 PM
Servlet problem Ravi Kumar Servlets 1 June 20th, 2005 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.