File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet Newbie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Newbie" Watch "Servlet Newbie" New topic
Author

Servlet Newbie

Jeff S
Greenhorn

Joined: Jun 26, 2001
Posts: 2
I'm writing my first servlet and I am having a problem. I am using JRun with IIS. I am trying to call a servlet from an html form. What do I put in the action command of the form? <form method="post" action=[some one help me here]>. Also, how is the servlet compiled? How is the .class file generated? Basically, how do I compile the servlet? Thanks
SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
<form method="post" action="....">, you must supply the target of this html, i.e., by taking action on this form element, the associated servlet will handle the request from this form. Servlet is just a java class file with diferent construct. Compile your servlet as regular java source file. You need to know Java before diving into servlet, otherwise you will have many difficulties in the future in this field.
Jeff S
Greenhorn

Joined: Jun 26, 2001
Posts: 2
I have a directory called /project-db and a context path of the same name. In the top level directory, my html form exists. In a subdirectory, I have web-inf/classes file, where my servlet resides. So my html form is located in /project-db and my servlet is located in /project-db/web-in/classes/MyServlet.
Knowing this, what goes into the action attribute of the form element within the html form? That is <form method="post" action=[WHAT GOES HERE?]>.
Thanks
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
JavaRanch has a Naming Policy In order to be entered in the drawing for the book giveaway, your name must meet this policy. Please reregister with a correct name.
Try
action="/project-db/servlet/MyServlet"
That will work with any servlet 2.2 compliant server.
------------------
Hope This Helps
Carl Trusiak, SCJP2


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

Jeff,
It would be:

-Ryo
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
Your "action" thing should look like this
action=http://<YourServerName>/<YourApplicationName>/servlet/<ServeletName(without .class extention)
<YourServerName> : name of ur server(eg www.abc.com)
<YourApplicationName> : The name of your webapplication if you have created one.this maynot be the same as your directory name which in your case is /project-db.Try to remember what name did u give to your application while setting up the JMC.you can find it out by logging in to JMC again.
Since you have put the servlet in /classes directory you have to use /servlet.JRun automatically translates /servlet to /web-inf/classes.
go thro the JRun documentation.Its very useful.
Subbu
Originally posted by Jeff S:
I have a directory called /project-db and a context path of the same name. In the top level directory, my html form exists. In a subdirectory, I have web-inf/classes file, where my servlet resides. So my html form is located in /project-db and my servlet is located in /project-db/web-in/classes/MyServlet.
Knowing this, what goes into the action attribute of the form element within the html form? That is <form method="post" action=[WHAT GOES HERE?]>.
Thanks


Subbu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Newbie