alcina 0 Newbie Poster

hi, i need to write a program that ask the user for first name, lastname, day of birth, day, month year, using a html form, and print out the user info using a servlet, and when user type in the number of month, the output will have to be in String, but just for month, for example: December23,2012, at first, i try to make a HTML form that ask user to enter name and lastname, and the servlet seems to working find, after i add the day of birth...only the html code work, but it can't access the servlet, can anyone help me?im using netbean 7.1,thanks!

here is my html code

<html>
    <head>
        <title>This is the form that will run a servlet
        </title>
    </head>
    <body>
        <form action="PickUpName" method="get">
            <label>First name: </label>
            <input type="text" name="firstName" size="30"/>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label>Last name: </label>
            <input type="text" name="lastName" size="30"/>
                        <label>Day: </label>
                        <input type="text" name="day" size="30"/>
                        <label>Month: </label>
                        <input type="text" name="month" size="25"/>
                        <label>Year: </label>
                        <input type="text" name="year" size="30"/>
            <input type="submit" value="Click"/>
        </form>
    </body>
</html>

and here is my servlet

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PickUpName extends HttpServlet
      {
           public void doGet (HttpServletRequest request, HttpServletResponse response)
           throws IOException, ServletException
                 {
                      response.setContentType ("text/html");
                      String fName = request.getParameter ("firstName");
                      String lName = request.getParameter ("lastName");
                      int Day = Integer.parseInt(request.getParameter ("day"));
                      int Month = Integer.parseInt(request.getParameter ("month"));
                      int Year = Integer.parseInt(request.getParameter ("year"));

                      PrintWriter out = response.getWriter ();
                      out.print ("<html>");
                      out.print ("<head>");
                      out.print ("<title>This title is created by the servlet");
                      out.print ("</title>");
                      out.print ("</head>");
                      out.print ("<body>");
                      out.print ("<h1>" + "Hello" + " "+ fName + " " + lName);
                      out.print ("</h1>");
                      out.print ("<h2>" + "You Entered: " + NumtoString(Month)+" "+Day + " " +Year+ " " + lName);
                      out.print ("</h1>");
                      out.print ("</body></html>");
                  }
           public String NumtoString(int month){

                            String monthString;
                            switch (month) {
                                case 1:  monthString = "January";
                                        break;
                                case 2:  monthString = "February";
                                        break;
                                case 3:  monthString = "March";
                                        break;
                                case 4:  monthString = "April";
                                        break;
                                case 5:  monthString = "May";
                                        break;
                                case 6:  monthString = "June";
                                        break;
                                case 7:  monthString = "July";
                                        break;
                                case 8:  monthString = "August";
                                        break;
                                case 9:  monthString = "September";
                                        break;
                                case 10: monthString = "October";
                                        break;
                                case 11: monthString = "November";
                                        break;
                                case 12: monthString = "December";
                                        break;
                                default: monthString = "Invalid month";
                                        break;
        }
                return monthString;          
       }
      }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.