• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling "/servlet/MyServlet" from HTML form

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bob,
Try "http://localhost:8080/servlet/MyServlet" or Just "servlet/MyServlet" (I Removed a '/').
Regards,
Holla.
 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I tried "servlet/MyServlet" in FORM ACTION, but tomcat can not find it.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic