Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a Textarea from a form in a servlet 1

Status
Not open for further replies.

timesign

Programmer
May 7, 2002
53
US
Hi,
I am having trouble here, the req.getparameter is returning null. (as tested by system.out.println)
I guess it is something simple i just don't understand.


[ I have put text in the textarea and have tried a variety of tests to prove that my problem line seems to be
InputFile = rq.getParameter("file"); returns null.
It actually errors and prints stack trace by
StringReader isr = new StringReader(InputFile); ]


the Html Page ----------------------------
<FORM ENCTYPE="multipart/form-data"
method="POST" ACTION="/servlet/StringConversion">
<Textarea rows=10 cols=40 name="file"></textarea>
<BR>
<INPUT TYPE="submit" VALUE="Translate File">
</FORM>

the servlet---------------------------------

String InputFile = new String();
InputFile = rq.getParameter("file");
System.out.println(InputFile);

try{
StringReader isr = new StringReader(InputFile); //this is
// of course where it errors out as the string=null.
BufferedReader in = new BufferedReader(isr);

-----------------------------------------
Thanks a load!!
 
Looks like the jsp doesn't like the enctype form attribute, as it works fine when you remove it.
Code:
<form method="POST" action="/servlet/StringConversion">
<textarea rows="10" cols="40" name="file"></textarea>
<br>
<input type="submit" value="Translate File">
</form>
And the jsp
Code:
String InputFile = new String();
InputFile = request.getParameter("file");
System.out.println(InputFile);
Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top