• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

getParameter

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Atul i had this small doubt
 
Ranch Hand
Posts: 133
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are right, the answer is 3 and 4.
 
It's exactly the same and completely different as this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic