Invoke servlets HTML Forms in Java source Coding

Aim
To invoke servlets from HTML Forms CS1404 INTERNET PROGRAMMING LABORATORY
Algorithm
Start the Invoking Servlets from HTML Forms
Create the postparm.html
Use the two input type for Employee name and phono
The save the postparm.html
Create java serve let for invoke the html forms
After creating java servlets extracting PostParam.war .
Then follow the step
Step 1: Open Web Browser and type
Step 2: http://localhost:8080
Step 3: Select Tomcat Manager
Step 4: Deploy the war file and Run
Finally terminate the Invoking Servlets from HTML Forms
– Invoking Servlets from HTML Forms --
-- PostParam.html -- Source code java programming

<HTML>
<BODY>
<CENTER>
<FORM name = "postparam" method = "post"
action="http://localhost:8080/PostParam/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">
</body>
</html>


Invoking Servlets from HTML Forms source code java programming
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();
}
}
D:\PostParam\WEB-INF\classes>javac PostParam.java
D:\PostParam\WEB-INF\classes>javac PostParam.java
D:\PostParam\WEB-INF>type web.xml


Invoking Servlets from HTML Forms source code xml programing

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<!-- JSPC servlet mappings start -->
<servlet>
<servlet-name>PostParam</servlet-name>
<servlet-class>PostParam</servlet-class>
</servlet>
<servlet-mapping>


<servlet-name>PostParam</servlet-name>
<url-pattern>/PostParam</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>


D:\PostParam>jar –cvf PostParam.war .
added manifest
adding: PostParam.html(in = 410) (out= 220)(deflated 46%)
adding: WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/PostParam.class(in = 1156) (out=
643)(deflated 44%)
adding: WEB-INF/classes/PostParam.java(in = 519) (out=
272)(deflated 47%)
adding: WEB-INF/web.xml(in = 674) (out= 314)(deflated 53%)

Invoke servlets HTML Forms in Java source Coding


Invoke servlets HTML Forms in Java source Coding

Invoke servlets HTML Forms in Java source Coding

Related post