Hi, I have a question about calling a servlet from a HTML form from local host. I have a HTML page that is at C:\tomcat\webapps\ch2\Web-inf\classes\ThisHtml.html And it's supposed to call "/servlet/MyServlet" in its form. But tomcat can not find it! Should I change it to "http://127.0.0.1:8080/ch2/servlet/MyServlet"? Thank you in advance.
Raghavendra Holla
Ranch Hand
Joined: Jun 02, 2000
Posts: 58
posted
0
Hi Bob, Try "http://localhost:8080/servlet/MyServlet" or Just "servlet/MyServlet" (I Removed a '/'). Regards, Holla.
Bob Moranski
Ranch Hand
Joined: Nov 22, 2000
Posts: 177
posted
0
Hi, I tried "servlet/MyServlet" in FORM ACTION, but tomcat can not find it.
Arvind Karanth
Greenhorn
Joined: Nov 21, 2000
Posts: 7
posted
0
Hi Bob, Hope You have done the following before trying to run the servlet. [1] copy the .class file of the servlet to : jsdk1.2/../../web-inf/servlets [2] Start the server i.e. execute jsdk1.2/startserver.bat file
Once you have done all this write this in the HTML file: <FORM METHOD="POST" ACTION="http://localhost:8080/servlet/MyServlet"> <INPUT TYPE="SUBMIT" VALUE="SUBMIT"> </FORM> When you click on the submit button on the HTML page....I hope it works.
[This message has been edited by Arvind Karanth (edited November 23, 2000).]
P SOLAIAPPAN
Ranch Hand
Joined: Oct 20, 2000
Posts: 68
posted
0
Hi Bob Moranski, You are doing basic mistake in invoking servlets. First of all why you have kept "ThisHtml.html" in "classes" directory ?. The "classes" dir should not contain HTML files it should contain your servlet files or pakage. Have you defined "server.xml" which is in TOMCAT configuration dir ?. I thing you are using pakages in your servlets, hence your URL will be either http://127.0.0.1:8080/ch2/servlet/MyServlet or http://127.0.0.1:8080/servlet/ch2.MyServlet Keep your HTML or JSP files in "\ch2\ " directory If you keep your MyServlet.class in "\classes\ch2\" directory then The first line in your MYServlet.java will be "package ch2;" Include the following in your "server.xml" file <Context path="/ch2" docBase="webapps/ch2" defaultSessionTimeOut="30" isWARExpanded="true" isWARValidated="false" isInvokerEnabled="true" isWorkDirPersistent="false" />