sgaucho
asked on
large String problem
Hi,
I have a page A which loads users from a db and passes it into another page B as a String separated by ";".
In page B, I use a String Tokenizer to tokenize the string and for every string obtained, I display it along with a chkbox next to it..
The problem is when page B loads with the received String, it hangs. I found out that the problem is with the String length. If I send a shorter String, the page loads fine but the String I am passing has about 10000 characters (540 words separated by ;).
But what I found strange was that, I loaded this entire String into another variable in a test jsp and it worked fine..
How can I resolve this ??
TIA
I have a page A which loads users from a db and passes it into another page B as a String separated by ";".
In page B, I use a String Tokenizer to tokenize the string and for every string obtained, I display it along with a chkbox next to it..
The problem is when page B loads with the received String, it hangs. I found out that the problem is with the String length. If I send a shorter String, the page loads fine but the String I am passing has about 10000 characters (540 words separated by ;).
But what I found strange was that, I loaded this entire String into another variable in a test jsp and it worked fine..
How can I resolve this ??
TIA
ASKER
Its slightly more complicated than that.. didnt post the entire story before :)
Here´s the setup:
I have a JSP page C which has 2 iframes in it whose sources are JSP page A and JSP page B.
Page A loads the users from a db and hv chkboxes beside each user. Once the chkboxes are checked and a button on page C is cliked, a Javascript function collects all the users (generates a string separted by ;)whose chkboxes hv been checked, Loads a hidden field in page B with this value AND then, submits page B.
Thus, page B receives the values as a String in the request url and does what I hv explained above.
Hope this made some sense!
Here´s the setup:
I have a JSP page C which has 2 iframes in it whose sources are JSP page A and JSP page B.
Page A loads the users from a db and hv chkboxes beside each user. Once the chkboxes are checked and a button on page C is cliked, a Javascript function collects all the users (generates a string separted by ;)whose chkboxes hv been checked, Loads a hidden field in page B with this value AND then, submits page B.
Thus, page B receives the values as a String in the request url and does what I hv explained above.
Hope this made some sense!
> Once the chkboxes are checked and a button on page C is cliked, a Javascript function collects all the users (generates a string separted by ;)whose chkboxes hv been checked, Loads a hidden field in page B with this value AND then, submits page B.
Why can't you just post the checkboxes to pageB as you would normally if they were in a form?
OR you are going to have to have C submit to D, which stores the string in the session, then reloads B
if you see what I mean ;-)
I'm dizzy now ;-)
Tim
Why can't you just post the checkboxes to pageB as you would normally if they were in a form?
OR you are going to have to have C submit to D, which stores the string in the session, then reloads B
if you see what I mean ;-)
I'm dizzy now ;-)
Tim
Are you saying that after you receive the request (in B), you can put/display the entire string in/from a jsp variable but you cannot process it with the StringTokenizer?
ASKER
Hi Tim,
Your soln for posting the chkboxes directly frm page A to B wud probably work fine but that would need to me to start all over again.. Isnt there a simpler workaround ?
btw, how can I post a form from one iframe to another iframe ? putting a target in the form tag doesnt seem to work..
@ Mr_It, nope the problem was what Tim pointed out, the request url is not receiving the entire string..
Your soln for posting the chkboxes directly frm page A to B wud probably work fine but that would need to me to start all over again.. Isnt there a simpler workaround ?
btw, how can I post a form from one iframe to another iframe ? putting a target in the form tag doesnt seem to work..
@ Mr_It, nope the problem was what Tim pointed out, the request url is not receiving the entire string..
ASKER
Nevermind bout the target.. its ok now..
anycase, wud be much happier if I can resolve this problem without recreating the soln..
thnx
anycase, wud be much happier if I can resolve this problem without recreating the soln..
thnx
I don't think you can... You can't put that many chars into an HTTP-GET (url string), and you can't get at the session from inside javascript... So you will have to post the form, and put it in the session, and reload the other page (as far as I know) :-(
ASKER
hmm.. wudnt it be possible to write to different hidden fields ?? i.e. when Page C is reading values and writing them to a hidden field in B, instead of writing all the values into the same hidden field, why not write to 3 or 4 hidden fields in B before submitting B ? Not that I like doing this but trying a last ditch op before starting again! ??
Meanwhile, apparently my prob with submitting iframe is not solved as I had thought ? So, How can I submit a form in one iframe to another iframe ?? just target doesnt seem sufficient..
thnx
Meanwhile, apparently my prob with submitting iframe is not solved as I had thought ? So, How can I submit a form in one iframe to another iframe ?? just target doesnt seem sufficient..
thnx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you using
do_get() method.
If you are using do_get().
Then try to change to d0_Post().
bcoz there is lenght of characters in posting with do_get method.
I think this might be the problem
please get back
Prasannaa
do_get() method.
If you are using do_get().
Then try to change to d0_Post().
bcoz there is lenght of characters in posting with do_get method.
I think this might be the problem
please get back
Prasannaa
ypu can try
StringBuffer
StringBuffer sBuffer = new StringBuffer();
sBuffer.append("Text");
sBuffer.toString();
Good luck
StringBuffer
StringBuffer sBuffer = new StringBuffer();
sBuffer.append("Text");
sBuffer.toString();
Good luck
I think I was right in saying that it needed a re-write...passing 10K chars in the URL is never a good idea...
That's probably a bad idea, as some browsers only support a certain length for Strings...
What you can do, is stick it in the session between pages...
in jsp1:
<%
session.setAttribute( "data", aReallyReallyLongString ) ;
%>
then, in jsp2:
<%
String reallyLongString = (String)session.getAttribu
session.removeAttribute( "data" ) ;
if( reallyLongString == null )
{
out.println( "<h1>data was null!</h1>" ) ;
}
%>