Re: Servlets (From Janet)
If you are using jsdk2.1 or jswdk then you have to
place the class files under webpages/WEB-INF/servlets directory
( not in the webserver root dir , which is 'webpages' in this case)
and then in the html form you have to write ACTION="/servlet/FirstServlet"
I hope your servlet class file name is FirstServlet.Other wise It won't work.
Now if you want to call the servlet as "MyServlet" instead of "FirstServlet"
where "FirstServlet" is your servlet Class file name
then Do the Following :
Create an alias for the servlet ..
in the WEB-INF directory you have a file called servlet.properties
append the following line to the file
<your package name(if you have any)>.FirstServlet
"Janet" <firstname.lastname@example.org> wrote:
>Thanks a million Sharad,
>I had compiled my java pgm and placed the class file in root directory of
>the web server. I then tried accessing the class file by including action="Firstservlet"
>in the form tag ... but in vain , since it gave me an error.
>Can you tell me , that if I have Microsoft Personal Web Server( or any other
>server as for that matter ) how will I know whether it does support servlets?
>"Sharad Joshi" <email@example.com> wrote:
>>If the web server which you are running supports Servlets, then you can
>>the servlet from the browser too. For example, you have a form in the HTML
>>page, after user enters his/her data in the fields, you would like that
>>to be passed to a servlet using the action=<servlet_name> attribute of
>>form. You can then utilize objects of type HttpServletRequest and HttpServletResponse
>>in the servlet. That way, a servlet can be called from the browser.
>>As far as books are concerned, there are 2 books I'll recommend (1) Professional
>>Java Server Programming - Wrox Publications (2) Java Servlets - Jason Hunter
>>Feel free to write to my email address or post in the discussion group.
>>"Janet" <firstname.lastname@example.org> wrote:
>>>Can we run a servlet without the servletrunner provided alongwith jsdk.
>>>if we have a web server running can we access a servlet thru an html code
>>>by placing the servlet in the server side ?
>>>Since I am new to Java, can you also suggest me a good site/book for servlets
>>>Thanks in advance,
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center