Make a class named Main.java after through the following steps. From step: 10 is related to your Main.java. Copy/paste your Main.java under the word:
1. Make an empty folder for eclipse.
2. Make a server (Tomcat v7.0 Server).
3. Make a dynamic project named: Project
4. Make an html document in eclipse named: Main.html.
5. Replace the content of Main.html by the following:
<
To display name and age
6. Make a servlet named: Main.java.
7. Replace the class Main.java by the following.
Note: Only replace the class Main.java. Everything else is intact.
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Enumeration;
@WebServlet("/Main")
public class Main extends HttpServlet {
private static final long serialVersionUID = 1L;
public Main() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
Enumeration names = request.getParameterNames();
String name = (String)names.nextElement();
String value = request.getParameter(name);
String name2 = (String)names.nextElement();
String value2 = request.getParameter(name2);
System.out.println(value + " " + value2);
}
}