1.here is my form code:
<form method="GET" action="Add">
first-name: <input type="text" name="first-name" value=""/><br/>
last-name: <input type="text" name="last-name" value=""/><br/>
email-id: <input type="text" name="email" value=""/><br/>
<input type="submit" name="submit" value="join now"/><br/>
</form>
2.here is servlet fragment:
Enumeration<String> en=request.getParameterNames();
while(en.hasMoreElements()){
String param=en.nextElement();
PrintWriter pw=response.getWriter();
pw.print(param);
pw.println(request.getParameter(param));
here is output:
first-namevishal
emaildrunkendeathison@gmail.com
submitjoin now
last-nameanand
why is it not fetched in order?
after first-name last-name must come and then email and submit must come, right??
This isnt something specific to servlet. All server side technologies will behave the same way as the html form data consists of key-value pair. If you have any logic which expects the order to come, you may need to relook at it. Generally it doesn’t make any difference in what order you receive the data, what you receive is more important.