How do I send "unlimited" text in a parameter using "POST" in Ajax

I'm trying to send large amounts of text data to the server using POST rather than GET, using Ajax
However, I am only able to send a max of 9.76 kb
I start with a jsp page, which calls a javascript method that utilises Ajax, which sends the text in a parameter in a XMLHttpRequest object
to a servlet. The text is derived from options values in a multi select combo box.
Here's my code:
Code snippet from .jsp page:
        <table>
        <form name="form1" id="form1" method="POST">
           <tr>
              <td>
             <select name="sel" id="sel" multiple="multiple" size="0"></select>
          </td>
          <td>
             <input type="button" id="sendOpts" name="sendOpts" value="Send Options" onClick="jsObj.sendOpts()">
          </td>
          </tr>
       </form>
       </table>Code snippet from jsObj.js file:
//=================================================
// jsObj object
//=================================================
jsObj = new jsObj();
function jsObj() {
     this.sendOpts = function() {
          if(!confirm('Send Option Values?'))
               return;
          if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
               xmlhttp=new XMLHttpRequest();
          } else { // code for IE6, IE5
               xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          xmlhttp.onreadystatechange=function() {
               if(xmlhttp.readyState==4) { // 4 = The request is complete
                    if (xmlhttp.status==200 || window.location.href.indexOf("http")==-1) {
                         alert(xmlhttp.responseText); // When I copy and paste all the text from this alert to text editor and save the file, the largest the file can be is 9.76 kb.
          var url = 'testSize'; // Servlet that simply retrieves the sent String in a parameter and sends it back to this method
          var sel = document.getElementById('sel');
          var str = sel.name + '=';
          var delim = ':';
          for(var i = 0; i < sel.length; i++) {
               str += encodeURIComponent(sel.options.value + delim); // 'encodeURIComponent' encodes any special characters within the parameter values
          xmlhttp.open("POST",url,true);
          xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // This is needed for any POST request made via Ajax
          xmlhttp.send(str); // send the parameter and it's value to the servlet
}Code snippet from 'testSize' servlet:package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
public class TestSize extends HttpServlet {
     public synchronized void doGet(HttpServletRequest request,
          HttpServletResponse response) throws ServletException,IOException {
          PrintWriter out = null;
          try {
               response.setContentType("text/html");
          out = response.getWriter();
               String str = request.getParameter("sel");
               str = str.substring(0, str.length()-1); // cut off last delimiter
               out.println(str);
               } catch (Exception e) {
     public synchronized void doPost(HttpServletRequest request,
          HttpServletResponse response) throws ServletException, IOException {
          doGet(request, response);
}Any help greatly appreciated.
Edited by: Irish_Fred on Feb 25, 2010 5:14 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Yes, I tried that.
I set the "ACTION" of the form to the servlet and then used the form.submit() method to POST the text to the servlet.
i.e.: I selected many options in the select combo, concatenated them to one string, set the 'value' property of a form text field to
this string, did a 'form.submit()' to the servlet and I was able to send a much larger amount of text.
( The .txt file I saved from the resulting text equaled about 30 kb in size, so obviously I can send much more
data this way. )
However, I want to use Ajax, so I don't have to reload the page. I 'borrowed' the Ajax part of the code from a website:
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost2.shtml
and I presumed that because the author used "POST" as opposed to "GET", I would be able to send larger
chunks of data. Obviously not, or there's another reason for the limit of data I can send using my present code,
which I'm not seeing. I'm fairly new to jsp, Ajax & Servlets, so this is no surprise.
If anyone can point out to me where I'm going wrong, I'd greatly appreciate it. Cheers.

Similar Messages

  • How can I send a text with a picture attachment on my new iPhone5c?

    How can I send a text with a picture attachment on my new iPhone5c? It won't send or recieve!!.

    Does your carrier support it?
    Follow the steps in this guide.
    http://www.imore.com/how-send-photo-using-imessage

  • How do I send a text message to family members all at the same time

    How do I send a text message to family members all at the same time

    Open a new message and then add all the contact in the to:

  • How do i send group text message keeping everyones phone number private

    how do i send group text message keeping everyones phone number private?

    send via Messages.app or email?
    http://www.macworld.com/article/1166505/send_text_files_from_mac_to_ios_via_mess ages.html

  • HT3529 How can I send a text thread from my iphone to my email?

    How can i send a text message thread from iphone to gmail?

    You can send a text message from your iPhone to Gmail by addressing the text to the email address.
    You can also Copy/Paste the a message from text to an email.
    See the iPhone User Guide for more info about copying and pasting.

  • How do I send a text using messages from my macbook to an iPhone phone?

    How do I send a text using messages from my macbook to an iPhone ?

    I tried to send it to their phone number, but it said they were offline.  And they downloaded iMessage for the iPhone but it still wasn't sending from my computer.  Is there some kind of trick?

  • How do I send a text message to more than one contact

    How do I send a text message on my iPhone 4 to various friends? How do I create a "Group Contact"?, I never had to do it or sent them separate, but I think is time to learn.
    Thank you.

    Thank you so much, will do it.
    Happy Holiday Season!

  • How do I send a text to a group that I have in contacts?

    How do I send a text to a group that I have already in contacts?

    It sounds like your spouse's phone number got attached to your family's Apple ID. Your boys are signed in under Settings>Messages and probably Settings>FaceTime on their devices. There are a few ways to fix this:
    1.) If your boys have their own Apple ID(s), just go into Settings>Messages on each of their devices, sign out of your Apple ID, then sign into their Apple ID. You can create a new Apple ID for each of them (as long as they are 13 or older) straight from the device or by going to https://appleid.apple.com
    2.) Instead of using separate IDs, you can add an email address for each of the boys to your spouse's current Apple ID that they use to send/receive their own iMessages. From your spouse or boys' device(s), access Settings>Messages>Send & Receive>Add Another Email... Once you have added any email(s) needed, you can then access the Settings>Messages>Send&Receive menu from each of your boys' devices. The address you added for each boy should be the only thing checked under "You can be reached by iMessage at:" and "Start new conversations from." If either or both of your boys have iPhones, they may also have their phone # checked under each section. That's fine, as the main idea is to make sure that none of you or your spouse's info is selected in these screens.
    3.) Simplest of all: if your boys don't need to use iMessage, you can just logout from the Apple ID in Settings>Messages and turn off iMessage. If they have iPhones, your boys will still be able to send/receive SMS and MMS messages thru their carrier plan, but will not use iMessage at all. Alternately, if they do have iPhones, you could just sign out of the ID, and leave iMessage on, which would allow them to send/receive iMessages and SMS/MMS thru just their phone numbers.
    I would also recommend taking a look at http://support.apple.com/kb/TS2755 for assistance in troubleshooting Messages and http://support.apple.com/kb/HT5538 for an overview of the linking of cell numbers to iMessage.

  • How can a send a text?

    How I can send a text from my iPad.

    You can't send texts to a cell phone your iPad, but you can send iMessages (a special kind of text message, essentially) to other iPads, iPhones, or iPod Touches if they (and you) are running iOS 5.0 or later and have iMessage set up and enabled. You do this through the Messages app. Make sure it's on in Settings > Messages.

  • HT3529 Isn't it misleading to say you can send unlimited texts via iMessage?

    Everything I read on the Apple web site says that you can send unlimited texts via iMessage on WiFi or SMS.  However, unless you have unlimited data, iMessages can eat up all of your data plan.  I know, because it happened to us on our AT&T plan.  So shouldn't you warn folks about that?

    Everything I read on the Apple web site says that you can send unlimited texts via iMessage on WiFi or SMS.
    No, not at all. You are confused  about iMessage, SMS, and data.  iMessage over WiFi doesn't use any cellular data.  iMessage over cell data connection does use some data, but you are not charged per message. (No one said it was free. 
    Alsp . SMS are iMessage are not at all related - iMessage isn't "sent via SMS."  SMS is provided by your carrier and doesn't use any of your cell data at all (it uses the voice channels).  Note that MMS does use cell data,

  • HT3529 What does "Unlimited" mean here, "iMessage allows you to send unlimited text..."?

    "iMessage allows you to send unlimited text, photos, videos, locations, and contacts using Wi-Fi or cellular data* " What does "Unlimited" mean here, since as far as I can tell, you have to pay for a text plan and none of them are unlimited?

    As long as you both have a data connection (either cellular or WiFi) the iMessage will be sent over the data connection and only use a tiny portion of your data allowance.
    If the recipient of the message does not have a data connection, the iMessage may switch over to a standard SMS text message (if you have allowed that option in the Settings) - in which case you may be charged by your mobile network operator for the SMS as you would any other SMS you send.
    Whether or not you are charged to receive SMS is something you'd have to ask your mobile network provider.

  • How can I send a message to multiple contacts using "groups".

    How can I send a message to multiple contacts using "groups".
    It was easy on my sony ericssonn....do i need to download an app?

    There is no group send option like you are looking for.
    To send to a group you have to pick each person you want to send to and send as a group that way. Then don't delete that SMS thread and you can reuse it again later.
    As for an app, well SMS works via your carrier and the OS, not something an App can do unless the app send the data to them (a third party) and then they relay it to the carrier. Do you really want to be sending your SMS to some 3rd party first?

  • How can I send an email from Sharepoint Online using sandbox solution?

    How can I send an email from Sharepoint Online using sandbox solution?
    If possible I do not want to use workflow.
    Is It possible to do it without using workflow?

    hello Steven Andrews,
    when any user sends a message using contact us page in SharePoint online.
    1. We are inserting item in Contact Us List . - This is working fine
    for anonymous users also. We have used Office365 anonymous codeplex wsp and it is working fine. Anonymous user is able to insert new record in the Contact Us List.
    2. Once, new record is inserted in Contact Us list, we want to fire email notifying thanks to the user on his email id as well as to our company x person for notification of new inquiry. 
    We tried using Workflow having impersonation step for  anonymous user but it is not working for Anonymous users. Workflow is able to sent the email if someone logged into system but not working for Anonymous user although workflow is getting started
    but not able to send email although used Imperonsation step.
    We are stuck into implementing second step.

  • How to link a search help to a parameter using which syntax

    hi
    how to link a search help to a parameter using which syntax

    Hi
    by useing this <b>F4IF_INT_TABLE_VALUE_REQUEST</b> you can creat a search help for a parameter on the screen
    under <b>AT SELCTION-SCREEN ON FIELD</b>
    write a selct query and store that values in the internal table and call that internal table in that FM
    <b>example</b>
    TYPES : BEGIN OF ST_OBJID_SH,
             OTYPE TYPE HRP1000-OTYPE,
             OBJID TYPE HRP1000-OBJID,
            END OF ST_OBJID_SH.
    DATA : IT_OBJID_SH TYPE STANDARD TABLE OF ST_OBJID_SH.
    DATA : WA_OBJID_SH TYPE ST_OBJID_SH.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_OBJID-LOW.
    *  IF S_OBJID IS NOT INITIAL.
        SELECT OTYPE OBJID FROM HRP1000
                     INTO TABLE IT_OBJID_SH
                     WHERE OTYPE = 'D'.
    IF SY-SUBRC EQ 0.
    * SEARCH HELP FOR QUALIFICATION.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
    *              DDIC_STRUCTURE         = ' '
            RETFIELD               =  'OBJID'
    *              PVALKEY                = ' '
           DYNPPROG               = SY-REPID
           DYNPNR                 = SY-DYNNR
           DYNPROFIELD            = 'S_OBJID'
    *              STEPL                  = 0
    *              WINDOW_TITLE           =
    *              VALUE                  = ' '
           VALUE_ORG              = 'S'
    *              MULTIPLE_CHOICE        = ' '
    *              DISPLAY                = ' '
    *              CALLBACK_PROGRAM       = ' '
    *              CALLBACK_FORM          = ' '
    *              MARK_TAB               =
    *            IMPORTING
    *              USER_RESET             =
          TABLES
            VALUE_TAB              =  IT_OBJID_SH
    *              FIELD_TAB              =
    *              RETURN_TAB             = RETURN_TAB
    *              DYNPFLD_MAPPING        =
    *            EXCEPTIONS
    *              PARAMETER_ERROR        = 1
    *              NO_VALUES_FOUND        = 2
    *              OTHERS                 = 3
        IF SY-SUBRC <> 0.
    *           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    <b>Reward if usefull</b>

  • How do I send a text from my iphone to an email address and have it be an imessage?

    I am trying to send a text message to my husband's ipad from my iphone via his email address.  He receives the text in his email and not as an imessage.  How can I change this so he receives it as an imessage. Our apple user id is my email address. 

    If you want your husband to receive an iMessage, you must send it to him as an iMessage yourself. Just go into the Messages app and send it to your husband's Apple ID. All e-mails (except me.com, as it is part of iCloud/iMessages) don't actually work with Messages.
    Alternatively, you could download free, wi-fi based messenger apps on your iDevices. Popular ones include WhatsApp, but there should be more that suit your preferences.

Maybe you are looking for

  • Problema com GRC e PI

    Olá pessoal Temos aqui o R/3 na versão 5.0 o GRC instalado no PI, como ja tinhamos o PI sendo utilizados em outras aplicaçoes no client 500, fizemos uma copy client criando o client 700 para usar na NFE, então temos 2 business system: 1 que aponta pa

  • Urgent: Error while uploading into pdf file

    Hi , I got a requirement that converting smartform into pdf file and sending into application server, And uploading the that pdf file into presentation server once a day am geting error when uploading into pdf format from application server . Error :

  • Component Status not updating since upgrade from SCCM2012 SP1 CU3 to SCCM2012 R2

    Since upgrading to SCCM2012 R2 three days ago, in the Configuration Manager console when we go to Monitoring > System Status > Component Status and view the status messages for any component, there are no entries since the time of our upgrade.  All c

  • Surely this is possible dataGrid html link..but suspicious absence on forum and net.

    Hi, Flash CS5 AS3 Having googled what I thought would have many instances of how its done, I have gotten nowhere, as have others with no replies to their postings. Google shows nothing for as3;  flex3 forum has something but we are not using flex. Is

  • F4 help in ALV Grid Control (using classes)

    Hi All,     I have created a report using ALV Grid control (using classes). I need to provide F4 help for some of the fields in the Grid control.  I couldn't understand the standard demo program BCALV_GRID_F4_HELP. So Can anyone please provide me sam