Solved

large String problem

Posted on 2004-08-19
15
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EJB MDB example 4 89
problem with  angularjs dropdwon search at object property (name) level 2 107
lessBy10  challenge 15 95
jsp error 6 49
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

696 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