Author Topic: Invoking Servlets from Html -A Simple Program For you  (Read 385 times)

0 Members and 1 Guest are viewing this topic.

Offline ebenzunlimited

  • Lead Admin
  • *****
Invoking Servlets from Html -A Simple Program For you
« on: June 06, 2012, 01:19:26 AM »
Html Code:



    <HTML>
        <head>
            <TITLE>INVOKING SERVLET FROM HTML</TITLE>
        </head>
    <BODY>
    <CENTER>
    <FORM name = "PostParam" method = "Post" action="http://localhost:8080/servlets-examples/servlet/serv">
    <TABLE>
    <tr>
    <td><B>Employee: </B> </td>
    <td><input type = "textbox" name="ename" size="25"
    value=""></td>
    </tr>
    <tr>
    <td><B>Phone: </B> </td>
    <td><input type = "textbox" name="phoneno" size="25"
    value=""></td>
    </tr>
    <tr>
    <td>Salary: </td>
    <td><input type="textbox" name="salary" size="25" value=""></td>
    </tr>
    <tr>
    <td>Id:</td>
    <td><input type="textbox" name="id" size="25" value=""></td>
    </tr>


    </TABLE>
    <INPUT type = "submit" value="Submit">
    </FORM>
    </CENTER>
    </body>
    </html>



Servlet Code:

    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    public class serv extends GenericServlet
    {
    public void service(ServletRequest request,ServletResponse response)throws ServletException,IOException
    {
    PrintWriter out=response.getWriter();
    String name=request.getParameter("ename");
    String phno=request.getParameter("phoneno");
    String sal=request.getParameter("salary");
    String id=request.getParameter("id");
    out.println("EmployeeName: "+name);
    out.println("Phone No:  "+phno);
    out.println("id:  "+id);
    out.println("Salary: "+salary);

    }
    }
Insane I Lived♥ Sane I Died♥<img src='http://i253.photobucket.com/albums/hh74/reallytired2/family%20pictures/buckeye%20stuff/clap.gif' />

 

* Post Updates

WPX is giving out 6 months of free WordPress hosting this week by obasimiracle
[November 25, 2020, 01:56:47 AM]


Re: Outlook PST Merge by ruth less
[November 11, 2020, 07:22:38 AM]


Re: How to Convert OLM to PST by priyankaarya
[November 10, 2020, 01:03:10 PM]

Inside: 3P Techies Blog

* Newest Techies

Get Updates


Sign up to get latest updates delivered to your inbox. No Spam, We Promise!

Get Hosting!

a Faster web hosting service

Copyright 3rd Planet Techies. All rights Reserved.

Top || Mobile ||Advertise || Contact Us || Privacy