• 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

Simple servlet implementation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am a beginner in the servlet world. I have installed Tomcat4.1 in my computer. Can any one tell me how to implement the "Helloworld" servlet with a link to a simple html "submit" button? It would be a great help for a beginner.
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend you to read the Head First Servlets and JSP book.

In short though, you need to set up TOMCAT_HOME, JAVA_HOME in your environment variables. Google for more info on those variables.

You need to have a Deployment Descriptor named web.xml which provides the mapping between your form(HTML page) and the Servlet.

more info : http://javaboutique.internet.com/tutorials/JSP/part03/
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Simply put
1) in the webapps folder make "mysite" folder, in that make "WEB-INF" folder and in that classes forlder

webapps
+ mysite
+ WEB-INF
+ classes


2) create a simple html file with action set to "http://localhost:8080/mysite/servlet/HelloServlet" and save it as index.html

the code will be...

<form action="http://localhost:8080/mysite/servlet/HelloServlet" method=get>
<input type=submit value="Go To Servlet">
</form>

3) create and compile a simple servlet


This servlet must have a doGet() method which print out the "Hello World"
message to client. This servlet class has to be in classes folder.

4) have web.xml (web descriptor) file in WEB-INF folder

5) go to your html page by typing http://localhost:8080/mysite/ in the web browser after starting tomcat and bingo....

For details do read the recommended book...

Maki Jav
 
reply
    Bookmark Topic Watch Topic
  • New Topic