File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes XML in Textarea problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "XML in Textarea problem" Watch "XML in Textarea problem" New topic
Author

XML in Textarea problem

Murad Iqbal
Ranch Hand

Joined: Dec 09, 2003
Posts: 90
Hello all,
I am trying to post XML in a textarea back to a jsp page, but apparently it doesn't contain anything when I check it on the server,

<form action="testXML.jsp" method="post">
<textarea name="theTextArea" rows="20" cols="60">
<dummy>
<xmltag>someData</xmltag>
<anothertag>moreData</anothertag>
</dummy>
</textarea>
<input type="submit" value="sendTheXML">
</form>



String xmlString=request.getParameter("theTextArea");

on the server, the xmlString is null.

What is going wrong?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I think its not something because of XML in textarea. You are probably losing the request object.

Have you tried any other input field there? Try it out.
Are you sure your textarea page is a JSP page? I mean not HTML. Not sure if it works from simple HTML to JSP or not.
Murad Iqbal
Ranch Hand

Joined: Dec 09, 2003
Posts: 90
Thanks Adeel for your prompt reply. Yes you are right here, the request object is getting lost somewhere, what can be the reason for it?

Following is the code sample for my work, I am using the same JSP page for input and processing

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%

String sTextXML = request.getParameter ("txtXMLArea") ;
if (sTextXML != null){

out.write("the XML is" sTextXML);
}
else
out.write ("no xml found") ;

String sTemp = request.getParameter ("txtTest");
out.write ("input:" + sTemp);
%>


<form id=frmValidator name=frmValidator action =Validate.jsp method=post>
<div id=objtxtArea name=objtxtArea >
<table align=center border=1>
<tr>
<td >
Paste XML in Text Area below
</td>
</tr>
<tr>
<td>
<textarea rows=20 cols=80 id=txtXMLArea value=""></textarea>
</td>
</tr>
</table>
</div>
<table align=center>
<tr>
<td><input type=text id=txtTest name=txtTest/>
<input type=button id=btnSubmit name=btnSubmit value="VALIDATE XML" onklick="callSubmit();" >
</td>
</tr>
</table>
</form>
Murad Iqbal
Ranch Hand

Joined: Dec 09, 2003
Posts: 90
thanks Adeel,
I managed to find the stupid mistake. I had put a value attribute in the textarea, secondly I hadnt defined a name for the textarea. Thanks for your help
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Glad to know, you made it.
BTW, in your first post the name attribute is defined.
Anyways, it is working now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML in Textarea problem
 
Similar Threads
trying to open a connection to a secure server (unknown certificate)
help! How to parse the XML file uploaded from clients?
How to pass xml as hidden parameter from a form
Passing cent symbol from jsp to servlet -- Problem
problems with sending parameter with textarea tag