• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML in Textarea problem

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic