which should i use in request.getParameter in servlet?

1.5k Views Asked by At

I'm using HTML5 where I use email as

<input type="email" id="txtEmail" name="email" required>

in the servlet page if i use String email=request.getParameter("email");

instead of

String txtEmail=request.getParameter("txtEmail");

will it be any problem??will it be error??plz help..

2

There are 2 best solutions below

0
On BEST ANSWER

You have to address the name Attribute of your input Elements Serverside. So if you would have <input type="text" name="username" id="userelementid"> then you would still use request.getParameter("username")

2
On

getParameter() method looks for the name attribute as your email input has the name email so you have to use request.getParameter("email");

txtEmail is an id so if you use String txtEmail=request.getParameter("txtEmail");

then you will get txtEmail=null