Author Topic: Invoking Servlets from Html -A Simple Program For you  (Read 424 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:

    <FORM name = "PostParam" method = "Post" action="http://localhost:8080/servlets-examples/servlet/serv">
    <td><B>Employee: </B> </td>
    <td><input type = "textbox" name="ename" size="25"
    <td><B>Phone: </B> </td>
    <td><input type = "textbox" name="phoneno" size="25"
    <td>Salary: </td>
    <td><input type="textbox" name="salary" size="25" value=""></td>
    <td><input type="textbox" name="id" size="25" value=""></td>

    <INPUT type = "submit" value="Submit">

Servlet Code:

    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='' />


* Newest Techies

Inside: 3P Techies Blog

Get Updates

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

Copyright 3rd Planet Techies. All rights Reserved.

Top || Mobile || Privacy