Link to home
Start Free TrialLog in
Avatar of donz4
donz4

asked on

problem with calling a servlet from a javascript using window.location

I am calling a servlet from a javascript using the following code:

pageUrl  = "/servlet/Main?ReportID=ADD&year=" + year1 + "&field2=" + field2 (etc, etc, etc)

location.replace('" "');
window.location = pageUrl;
return true:

i use this code all the time, but this time I am sending TONS of data, and it errors on the window.location line.  I am pretty sure it's because of the amount of data that I'm sending via the url.  I tested by limiting the amount of data and it works, but when I send all the data that is needed, it freaks out
with a javascript error that can't be captured and gives me a "page not found" error with the following in the url:

/servlet/"%20"

when it should be /servlet/Main?ReportID=ADD&year=2004&field2=field2 (etc, etc, etc)

Is there a limit to the amount of characters in a url?  And if so, how can I pass all my data to the servlet using a javascript?  Can I use putsession commands in a servlet?

HELP!


ASKER CERTIFIED SOLUTION
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please check this first.

pageUrl  = "/servlet/Main?ReportID=ADD&year=" + year1 + "&field2=" + field2 (etc, etc, etc)

I think there is one space in

"/servlet/ Main?......
            ^
             There is one space here!
If it is working fine with less data, then there nothing wrong with the code. I would say send data in array. That will be faster and easier.
--Raj