• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

doubt from jdiscuss

 
Ranch Hand
Posts: 383
  • 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?

Code

<html>

<body>

<form action="/myapp/SaveServlet" method="POST">

<input type="file" name="name">

<input type="submit" value="POST">

</form>

</body>

</html>


Options

Select 2 correct options.


1 request.getParameter("name");


2 request.getAttribute("name");


3 request.getInputStream();


4 request.getReader();
The answers are 3 & 4. I thought the answer is only 1. Anyone can explain?
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi dolly !!!

A request's parameter is a pair String/String.
request.getParameter("name"); will return you a String

Here name is a File you cannot get it with the method getParameter().

You have two posibilities:
  • Retrieve the body as character data using BufferedReader with the method getReader().

  • (public BufferedReader getReader() throws IOException )

  • Retrieve the body of the request as binary data using ServletInputStream with getInputStream().

  • (public ServletInputStream getInputStream() throws IOException )
    Hope It help.
    [ December 28, 2007: Message edited by: Collins Mbianda ]
     
    pie sneak
    Posts: 4727
    Mac VI Editor Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The input element is a file type which allows the user to upload a file.
     
    dolly shah
    Ranch Hand
    Posts: 383
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks to both of you. I got it now.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic