Servlet Sample Code with HTML(JSP) in TGMC

HTML CODE:
//JSP Program for Servlet.
<HTML>

<head>

<TITLE>INVOKING SERVLET FROM HTML</TITLE>

</head>

<BODY>

<CENTER>

<FORM name = "PostParam" method = "Post" action="http://localhost:9091/FC/PostParam">

<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>

</TABLE>

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

</FORM>

</CENTER>

</body>

</html>


Servlet Code:
//Servlet Code for JSP
import java.io.*;

import java.util.*;

import javax.servlet.*;

public class PostParam extends GenericServlet

{

public void service(ServletRequest request,ServletResponse response) throws
ServletException,IOException

{

PrintWriter pw = response.getWriter();

Enumeration e = request.getParameterNames();

while(e.hasMoreElements())

{

String pname = (String)e.nextElement();

pw.print(pname + " = ");

String pvalue = request.getParameter(pname);

pw.println(pvalue);

}

pw.close();

}

}