• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Get off me! Here, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic