0 Replies Latest reply on Mar 10, 2012 11:42 AM by rtskoo rtskoo

    Getting value using @Requestparam in servlet is alway the same.why

    rtskoo rtskoo Newbie

      I use @RequestParam to get value in servlet,but the value I got is alway the same one while different values were post from client ,what is the problem?

       

       

      import java.io.IOException;

      import java.util.List;

      import java.util.PropertyResourceBundle;

       

      import javax.inject.Inject;

      import javax.persistence.EntityManager;

      import javax.persistence.PersistenceContext;

      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 org.jboss.solder.servlet.http.RequestParam;

       

      import com.gxpost.efr.model.User;

       

       

      /**

      * Servlet implementation class Login

      */

      @WebServlet("/Login.do")

      public class Login extends HttpServlet {

          private static final long serialVersionUID = 1L;

       

          /**

           * @see HttpServlet#HttpServlet()

           */

          @Inject

          @RequestParam("login_name")

           String name1;

        

          public Login() {

              super();

              // TODO Auto-generated constructor stub

          }

       

          /**

           * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse

           *      response)

           */

          protected void doGet(HttpServletRequest request,

                  HttpServletResponse response) throws ServletException, IOException {

              // TODO Auto-generated method stub

             

          }

       

          /**

           * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse

           *      response)

           */

          protected void doPost(HttpServletRequest request,

                  HttpServletResponse response) throws ServletException, IOException {

             

                String name2=request.getParameter("login_name");

                System.out.println("name1: "+name1+"  name2: "+name2); // Name1 who gets the value of input 'login_name' in client has no change  for different input from client ,but name2 is OK

          }

       

      }