Hi Sanjay,
Have you considered picking up a good book on Servlets? I don't mean to
be rude, but your question appears to show you are getting off on the
wrong start to learning servlets. Usually a more comprehensive guide and
walk through helps. Take a look at Jason Hunter's "Java Servlet
Programming 2nd Edition", or Marty Hall's "Core Servlets and JSP." They
are both excellent titles. Marty's book is also freely available online
- http://pdf.coreservlets.com/.
As for you question, put all of your .class files in the
/WEB-INF/classes directory of your Web Application. If the class is part
of a package make sure to make sub-directories that match the package
name. The Java source files don't need to be in the same directory. You
then need to add an entry in to your Web Application's web.xml file to
properly map the servlet to a URL.
All of this can best be seen by looking at the examples Tomcat already has.
For some more help try looking on JSP Insider -
http://www.jspinsider.com. There are quite a few links to other servlet
resources including tutorials and sample book chapters.
Jayson Falkner
[EMAIL PROTECTED]
Sanjay Jadhav wrote:
> Hi..
> recently i installed tomcat 4.0.1, it installed prefectly, running prefectly all
>the examples but i get confiused about how should i run my own developed servlet in
>which directory should i put those .java and .class files,
> i sending the html file and servlet file, html take the input and send it to
>servlet and it will return the html file with user input..
>
> with best regards,
> sanjay jadhav
>
> servelt file as under..
> ------------------------
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.lang.*;
>
> public class ExampServlet extends HttpServlet {
> public void doPost(HttpServletRequest request,HttpServletResponse response)
>throws ServletException, IOException {
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
> out.println("<title>Example</title>" +
> "<body bgcolor=FFFFFF>");
>
> out.println("<h2>Button Clicked</h2>");
>
> String DATA = request.getParameter("DATA");
>
> if(DATA != null){
> out.println(DATA);
> } else {
> out.println("No text entered.");
> }
>
> out.println("<P>Return to <A HREF=../simpleHTML.html>Form</A>");
> out.close();
> }
> }
>
> html file as under
> -------------------
> <HTML>
> <HEAD>
> <TITLE>Example</TITLE>
> </HEAD>
> <BODY BGCOLOR="WHITE">
>
> <TABLE BORDER="2" CELLPADDING="2">
> <TR><TD WIDTH="275">
>
> <H2>I'm a Simple Form</H2>
>
> Enter some text and click the Submit button.<BR>
> Clicking Submit invokes
> <A HREF="ExampServlet.java">ExampServlet.java</A>,<BR>
> which returns an HTML page to the browser.
>
> <FORM METHOD="POST" ACTION="JSP/Servlet/ExampServlet">
>
> <INPUT TYPE="TEXT" NAME="DATA" SIZE=30>
>
> <P>
> <INPUT TYPE="SUBMIT" VALUE="Click Me">
> <INPUT TYPE="RESET">
> </FORM>
>
> </TD></TR>
> </TABLE>
>
> </BODY>
> </HTML>
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
>
> .
>
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
N�����r��zf���%��lz��j���w(�����Ƞ���%#�51$Ţ�b��-�����b����ڽ�.��&�+an�r��IH�
LDDI0�D�J����^���,�rR?����^��������j�m���j�!�����ڲ�ܢo㲘����m�Xm�����ڲ�ܢo鮇nr�?��}���ia���
0z�^�������?㲟㲗ڪ;)��i��0�8.��(��ګ��u�c��m����#����'^��&