Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML in Textarea problem

 
Murad Iqbal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to know, you made it.
BTW, in your first post the name attribute is defined.
Anyways, it is working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic