Hi everybody,
I am learing
java by myself and I am reading about
servlets and I have stuck. I have written the following html
<html>
<head>
<title>Select a Stock</title>
</head>
<body>
<form action="http://localhost:8080/servlet/ServLet1" method="GET">
Enter your name:
<input type=text value=Name>
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Also I have written the java servlet
public class ServLet1 extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
String name = request.getParameter("Name");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello world!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello world!</h1>");
out.println("<br>");
out.println("<h2>");
out.println("hi 1");
out.println(name);
out.println("</h2>");
out.println("</body>");
out.println("</html>");
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
I have install
tomcat on windows XP Professional
I call the html with firefox, I type in a name and press the submit button. The html of the servlet is displayed but the getParameter returns NULL. I have checked that the name is correctly written.
Does anybody has an idea why?
Thanks in advance.
Regards
Antonis