Calling a servlet from within an HTML page

Home  »  Java  »  Advance Java  »  Java Servlets  »  Calling a servlet


Servlets URLs can be used in HTML tags. This section shows servlet URLs being used as the destination of an anchor, as the action in a form, and as the location to be used when a METa tag directs that a page be refreshed.

To invoke a servlet from within an HTML page the servlet URL should be used in the appropriate HTML tag. Tags that take URLs include those that begin anchors, forms, and meta tags.

The following is a Survey form, which captures the user input as shown in diagram 24.18. On clicking the button 'Submit', the servlet i.e. Survey processes the data and returns a page, which displays the information entered in the form as shown diagram 24.19

Following is the source code of the HTML page i.e. Survey.html:




Diagram 24.18 Output of Survey.html



The following is the source code for Survey.class




Diagram 24.19 Output of Survey.class



Java Servlet Programming







2 comments:

  1. Good Post! Thank you so much for sharing the post, it was so good to read and useful to improve
    Java Training in Electronic City

    ReplyDelete
  2. Hello. Thank you for this programs and tutorials. To see the tutorials of c or cpp visit:
    http://bit.ly/2Rsri4w
    http://bit.ly/2RuE6Yf
    http://bit.ly/2Ly75qb
    http://bit.ly/33USD1X
    I am new blogger so visit my blog, Write comment for how can I improve my blog for you and audience.
    Thank You So Much.

    ReplyDelete