aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes RequestParameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "RequestParameters" Watch "RequestParameters" New topic
Author

RequestParameters

Swati Udas
Ranch Hand

Joined: Aug 18, 2004
Posts: 121
I came across the following question in a mock exam..

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>
Select 2 correct options.
A.request.getParameter("name");
B.request.getAttribute("name");
C.request.getInputStream();
D.request.getReader();
E.request.getFileInputStream();
ANS: C,D

I think the answer should be A. but the given ans id C,D.
Could someone help me understand how this works ?
Thanks in advance.


SCJP 1.4 (90%)<br />SCWCD 1.4 (88%)
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Swati said:
I came across the following question in a mock exam..

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>
Select 2 correct options.
A.request.getParameter("name");
B.request.getAttribute("name");
C.request.getInputStream();
D.request.getReader();
E.request.getFileInputStream();
ANS: C,D

I think the answer should be A. but the given ans id C,D.
Could someone help me understand how this works ?
Thanks in advance.


See the type, its file. So you are actually uploading a file.

Most importantly you are not setting the enctype to multipart/form-data
so you cannot send the file data. So you can just get the name of the file that user has uploaded by option A.

But if you have enctype="multipart/form-data" in the form tag, then you need to do getInputStream of getReader that is option C,D to get the actually uploaded content.
Swati Udas
Ranch Hand

Joined: Aug 18, 2004
Posts: 121
ok. got it.
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestParameters