Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

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
0
sgaucho
Asked:
sgaucho
1 Solution
 
TimYatesCommented:
Are you passing it in the request URL?

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.getAttribute( "data" ) ;
    session.removeAttribute( "data" ) ;
    if( reallyLongString == null )
    {
        out.println( "<h1>data was null!</h1>" ) ;
    }
%>
0
 
sgauchoAuthor Commented:
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!
0
 
TimYatesCommented:
> 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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Mr_ItCommented:
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?

0
 
sgauchoAuthor Commented:
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..
0
 
sgauchoAuthor Commented:
Nevermind bout the target..  its ok now..

anycase, wud be much happier if I can resolve this problem without recreating the soln..

thnx
0
 
TimYatesCommented:
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) :-(
0
 
sgauchoAuthor Commented:
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
0
 
TimYatesCommented:
Do you mean "IFRAME" or "FRAME"?

IFrame I have no idea...not even sure you can submit from one to the other...

> to write to different hidden fields

Can you post your code?  Are you passing it in hidden fields?  I thought you were building a query string up with javascript?  Are you setting hidden fields?

Splititing it into two hidden fields will just give you real problems in the future :-(

Adding another JSP is the only really neat solution...
0
 
ss_pCommented:
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
0
 
iglezCommented:
ypu can try
StringBuffer

StringBuffer sBuffer = new StringBuffer();

sBuffer.append("Text");

sBuffer.toString();


Good luck
0
 
TimYatesCommented:
I think I was right in saying that it needed a re-write...passing 10K chars in the URL is never a good idea...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now