| Author |
getParameter
|
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 832
|
|
How can you retrieve the data sent by the FORM displayed by following HTML page code? <html> <body> <form action="/myapp/SaveServlet" method="POST"> <input type="file" name="name"> <input type="submit" value="POST"> </form> </body> </html> 1)request.getParameter("name"); 2)request.getAttribute("name"); 3)request.getInputStream(); 4)request.getReader(); 5)request.getFileInputStream(); The correct answer given is 3 and 5. I agree. But why the answer given 1 is wrong, because there is a parameter name in the html. This is from Enthuware. Please advise.
|
SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
|
 |
Atul Samnerkar
Ranch Hand
Joined: Sep 20, 2003
Posts: 44
|
|
1. In the given example html input "type" is "file" and not "text". 2. getParameter() returns you a String. 3. Being we are tring to access the file request object, we will not get String. Hence this answer is wrong. Thanks, Atul Samnerkar [ August 30, 2008: Message edited by: Atul Samnerkar ]
|
 |
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 832
|
|
|
Thanks, Atul i had this small doubt
|
 |
Krzysztof Koziol
Ranch Hand
Joined: Nov 19, 2006
Posts: 133
|
|
Originally posted by Amandeep Singh: 5)request.getFileInputStream(); The correct answer given is 3 and 5. I agree.
The getFileInputStream()? Such a method doesn't exist in the HttpServletRequest and in the ServletRequest API. Where did you find it? Regards, Krzysztof [ August 31, 2008: Message edited by: Krzysztof Koziol ]
|
SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
|
 |
siyabonga khanyile
Greenhorn
Joined: Aug 22, 2008
Posts: 12
|
|
|
The answer should be 3 and 4...we can use both InputStream getInputStream() and BufferedReader getReader()
|
 |
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 832
|
|
|
you are right, the answer is 3 and 4.
|
 |
 |
|
|
subject: getParameter
|
|
|