aspose file tools*
The moose likes Servlets and the fly likes Calling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling "/servlet/MyServlet" from HTML form" Watch "Calling "/servlet/MyServlet" from HTML form" New topic
Author

Calling "/servlet/MyServlet" from HTML form

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
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
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
Hi, I tried "servlet/MyServlet" in FORM ACTION, but tomcat can not find it.
Arvind Karanth
Greenhorn

Joined: Nov 21, 2000
Posts: 7
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
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" />

solaiappan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling "/servlet/MyServlet" from HTML form
 
Similar Threads
Deploying My WebApp in Tomcat
Servlet call error: 404 servlet call not available
Servlet Not Working
Help Me
doPost and doGet