Solved

large String problem

Posted on 2004-08-19
15
162 Views
Last Modified: 2010-04-01
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
Comment
Question by:sgaucho
15 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11839291
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
 

Author Comment

by:sgaucho
ID: 11839414
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
 
LVL 35

Expert Comment

by:TimYates
ID: 11839657
> 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 4

Expert Comment

by:Mr_It
ID: 11839698
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
 

Author Comment

by:sgaucho
ID: 11839905
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
 

Author Comment

by:sgaucho
ID: 11839921
Nevermind bout the target..  its ok now..

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

thnx
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839956
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
 

Author Comment

by:sgaucho
ID: 11840084
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
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
ID: 11840159
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
 
LVL 3

Expert Comment

by:ss_p
ID: 11842089
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
 

Expert Comment

by:iglez
ID: 11896998
ypu can try
StringBuffer

StringBuffer sBuffer = new StringBuffer();

sBuffer.append("Text");

sBuffer.toString();


Good luck
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12492027
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question