This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't display large amounts of text - help

 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form that allows a user to cut and paste text into an HTML text area and then submit to a second page which will display what they have submitted.
I am using request.getParameter(""); to retreive the submitted text. My problem is if the user cuts and pastes a large amount of text and then submits - it breaks
If the text isn't quite as long - it submits fine.
Is there another way to capture large chunks of data that is submitted through a form? (like the size of a magazine article)
It's like the request.getParameter("") will only accept a certain amount of data and then break.
Anyone heard of this?
Any ideas?
Thanks
Mark

------------------
A gentle push and a mild arc, and the cowhide globe hits home - Hot Rod Hundley
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mark
well you are right. Both netscape and IE have certain maximum length for the url in the address field..so using the request.getParameter your program will cause problems for passing paragraphs.
what you can do is use Beans and bind it to the session . and on the next page get the value using some getXXX method.
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dharmesh for your insight.
I have a few more questions now ....
1)
I'm not sure what you mean by
<b>"Both netscape and IE have certain maximum length for the url in the address field..so using the request.getParameter your program will cause problems for passing paragraphs."</b>
I am passing all data by "post" so none of it gets passed via the URL.
2)<b>...what you can do is use Beans and bind it to the session . and on the next page get the value using some getXXX method.</b>
How is this done? do I pass the string into a session var and then call it? If so, I have already tried something like this and got the same result.
Any code or explanation would be helpful


Mark
------------------
A gentle push and a mild arc, and the cowhide globe hits home - Hot Rod Hundley
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing all data by "post" so none of it gets passed via the URL
since you are passing using method="POST" data is passedas a seperate section following the HTTP header. and the header also has a limited length beyond which passing of data wont occur.
as far as the second solution is concerned.. when i thought about it .. me too got into slight confusion and and figured that the second method i mentioned will not work as required.. but i am trying to get a solution so will get back to you in no time.. in the mean time in case you get the solution .. notify me .
------------------
IBM Certified WebSphere Application Server V3.5 Specialist
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In theory, at least, the amount of data you can submit in a POST is unlimited. What I suspect is more likely is that there's a maximum capacity in the the textarea controls themselves like the old Windows 64K limit. If so, that contstraint would be imposed by the browser. To get around it, you'd probably have to use a Java applet or ActiveX that could be pasted to.
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again for your input. I seriously can't believe there isn't a good way to input a chunk of text and pull it out.
I am developing a content management system that allows office staff to update their own website via a form and haven't had any problems retrieving most text using the getParameter("") method.
It just breaks when the text reaches a certain length.
Is there a buffer control that can be used?
thanks again,
Mark
------------------
A gentle push and a mild arc, and the cowhide globe hits home - Hot Rod Hundley
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone have any ideas?
I am completely stumped.
Mark
------------------
A gentle push and a mild arc, and the cowhide globe hits home - Hot Rod Hundley
 
Frank Lin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
What is the exact error message? What is the size of text when it starts causing problem?
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I submit 8-10 paragraphs of text the browser crashes - I get "the page cannot be displayed" or if I refresh - I get a "null error" But if I submit 5-6 paragraphs through the text area - it submits fine and displays.
I really think there is a buffer or browser limit to how much text you can submit - but I'm not sure.
Again, any help is appreciated.
Mark
------------------
A gentle push and a mild arc, and the cowhide globe hits home - Hot Rod Hundley
 
Frank Lin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
is there any error message on the server side when it breaks? How do you know it breaks at getParameter()? If you see some errors on the server side, then it does not look like browser issue(I doubt about it). Can you add some println statements in your servlet program to see exactly where it breaks? By the way, what application server or servlet container do you use?
 
Mark Stringham
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I submit a large amount of text through the form and then submit - like I said - I get "this page cannot be displayed" error. If I then refresh, I get a "null" error. I can't even display a results page to see where or if an error has occurred.
I am using JRUN 3.0 as my app server.
Thanks
Mark
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
I suppose you have to pass a chunk of text to another page without any page.
Could you try this?
capture the text in a String variable.
in the source page
request.setAttribute("chunk", text);
in the destination page use
String text = request.getAttribure("chunk");
and try to print
Correct me if i am wrong or misunderstood your question
Thanks
Binu
 
Jian Zhang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe the default value of your browse set the 'wrap' attribute to off, so use wrap=virtual to return data which is not broken and wrap=physical to send data with newline characters
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are using a MSIE browser, if so, it might help to turn off "friendly" error messages so you can see exactly what the servlet returns. Tools ->Internet Options -> advanced - uncheck "friendly error messages."
Bill
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this problem can be resolved by setting the same text value in Session as setAttribute.
And then fetching the attribute value
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic