• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameter

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Atul i had this small doubt
 
Krzysztof Koziol
Ranch Hand
Posts: 133
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
siyabonga khanyile
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer should be 3 and 4...we can use both InputStream getInputStream() and BufferedReader getReader()
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right, the answer is 3 and 4.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic