Subject: servlet problem
Posted By: discuss Post Date: 8/24/2006 6:26:45 AM

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
Reply By: elishae Reply Date: 8/29/2006 10:03:10 AM
Modify your Hello.htm to use

<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




Go to topic 48978

Return to index page 191
Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182