[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

request.getParameter - max size limit?

Posted on 2006-04-11
30
Medium Priority
?
3,814 Views
Last Modified: 2012-05-05
When the user enters a really long string (around 100 lines of text) into a textbox and in the following page, when I call request.getParameter("input"), I am getting a null pointer exception.

I tried to print request.getParameter this way
logger.severe(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REQPARAM is" +request.getParameter("input"));

It prints the first 90 or so lines and then stops printing.

Does request.getParameter have any limit on max size and what are my options?

0
Comment
Question by:mytilig
  • 11
  • 10
  • 4
  • +3
30 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 16431479
Did you try changing your form method from "get"  to "post"  ?
0
 

Author Comment

by:mytilig
ID: 16431554
It is already POST
Also I just added  buffer="128kb" in my page tag. same error still.
Note that there is no error for smaller texts(smaller than 90 lines)

Thanks.
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 16431684
are you using input type="text" or a textarea?
0
Independent Software Vendors: 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!

 

Author Comment

by:mytilig
ID: 16431763
textarea
0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 16432752
I don't think request.getParameter() has any limit especially in POST method.

can you put forward the JSP textarea code

it must be some thing like.

<input type="textArea" name="input" ...../>

am i correct ?

please just check if you have specified the name correctly.
0
 

Author Comment

by:mytilig
ID: 16432994
Here is the textarea tag in my initial jsp page.  
<textarea name="input" cols="55" rows="15"><%=emp.getDevTxt()%></textarea>

The text area will have default value from database.  

Everything works correctly for < 7399 characters (around 90 lines)
Above this size, I get the null pointer exception.

I have increased jsp buffer to 128kb like this buffer="128kb"
no luck still....
0
 
LVL 28

Expert Comment

by:rrz
ID: 16433085
>I have increased jsp buffer to 128kb like this buffer="128kb"
I don't think that is the problem. I am guessing  you might be hitting one of these.
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#88659 
What does just  <%=emp.getDevTxt()%>   output  ?  
0
 

Author Comment

by:mytilig
ID: 16433136
Additional note:

I printed request.getContentLength(), found that my application works correctly until request.getContentLength()<= 7633 bytes.
If I add another character into my text area, request.getContentLength() becomes 7634 bytes and my app crashes....


<%=emp.getDevTxt()%> does print all my text intact. It is only when I pass it as a variable and retrieve it using request.getParameter that I have the issue.
Thank you.

0
 
LVL 12

Expert Comment

by:jessegivy
ID: 16433193
Hi, I'm perplexed.

I have to agree with shivaspk and take it a step further by saying that errors are rarely what they seem to be.  Let's see some code if you really need an answer.  Where you're having a problem is right at the request/response model so ensure that all surrounding code is completely in tact and you should be fine.

...really stumped on this one.  I'd love to see some code here!
0
 

Author Comment

by:mytilig
ID: 16433233
Here is the code snippet from my main JSP page

<script type="text/JavaScript">
function draft_btn()
{
      alert("Saving data ");
      document.empForm.action = "EmployeeDraft.jsp";
      document.empForm.submit();                  // Submit the page
      return true;
}
</script>

<form name="empForm" method="post" > 
<table> <tr><td>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="209" valign="top"><img src="../images/Values.jpg" width="180" height="277" /></td>
                    <td width="5" valign="top">&nbsp;</td>
                    <td align="left" valign="top"><span class="style9"><strong>Development Text : <br>(List a minimum of three)   &nbsp; &nbsp;&nbsp;
</strong> </span>
                        <br />
                     
                        <textarea name="dev" cols="55" rows="15"><%=emp.getDevTxt()%></textarea>
                        <br /></td>
                  </tr>
              </table> </tr></td>

<tr>
                    <td><input name="draft" type="button" id="draft" value=" Save Draft " OnClick="return draft_btn();" />
                      </td> </tr> </table>
</form>
</body>
</html>

Here is the code snippet from 2nd jsp page

if (request.getParameter("dev") !=null ) {
logger.severe("Request size is " +request.getContentLength());
logger.severe(" MM..............    "+Runtime.getRuntime().maxMemory() + "free >>>> " +Runtime.getRuntime().freeMemory());
logger.severe(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REQPARAM is" +request.getParameter("dev"));
}


0
 

Author Comment

by:mytilig
ID: 16433674
I have simulated it using a simpler version of the code

test1.jsp
---------------------

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="test2.jsp">
  <label>ip
  <textarea name="ip" id="ip"  cols="55" rows="15"></textarea>
  </label>
  <p>
    <input type="submit" name="Submit" value="Submit" />
  </p>
</form>
</body>
</html>


test2.jsp
---------------------
      <%@ page import="java.util.logging.*" %>
      <html>
      <body>
            <%
      Logger logger = Logger.getLogger("test2");
      if (request.getParameter("ip") !=null ) {
            logger.severe("REQPARAM is" +request.getParameter("ip"));
}
%>
</body></html>
0
 
LVL 35

Accepted Solution

by:
TimYates earned 1000 total points
ID: 16434015
>> I have simulated it using a simpler version of the code

And that crashes?

How about this:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
  </head>
  <body>
    <form method="post">
      <label>ip
        <textarea name="ip" cols="55" rows="15"></textarea>
      </label>
      <p>
        <input type="submit" name="Submit" value="Submit" />
      </p>
    </form>
    <%= request.getParameter( "ip" ) %>
  </body>
</html>

That works for me...
0
 
LVL 28

Assisted Solution

by:rrz
rrz earned 1000 total points
ID: 16435859
What app server are using ?  I have trying on Tomcat 5.5  and I do see that ther is a upper limit. I haven't found it yet though.  Here is what I am using to test.  First page is just html.
<html>
</body>
<form name="empForm" method="post" action="http://localhost:8080/test.jsp">
                        <textarea name="dev" cols="55" rows="15">
</textarea>
<input type="submit"/>
</form>
</body>
</html>

and test.jsp is simply  

<%
  String dev = request.getParameter("dev");
%>
<%=dev%>

I  can't explain the limitation but then I see what your talking about here.    rrz
0
 
LVL 28

Expert Comment

by:rrz
ID: 16435912
I am just paste different size text block into the textarea and getting redirected to  FakeServlet by Tomcat(which is unavailable) if it too large. Very strange ! A behavior I have not seen before. How about you TIm ?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16435926
(that's the same as my code rrz, just split into 2 files) ;-)

hehe
0
 
LVL 2

Expert Comment

by:borislavmarkov
ID: 16436329
Hallo, I had once same problems, around 8kb of text brokes the text. I was using JETTY with JBOSS.
Is your situation the same.

I think I solved my problem with another trick like using:

******
request.getInputStream()
******

and reading rough data.
Try this solution.

Please tell us your environment OS/WEB Container/JVM/BROWSER/etc...
0
 
LVL 28

Expert Comment

by:rrz
ID: 16436535
I was wrong. I don't see the problem. I mistakenly cut and pasted code.  When I cut and pasted plain text I had no problem with over 400 KB.
0
 
LVL 28

Expert Comment

by:rrz
ID: 16436548
mytilig    Did you try  without looger code  ?  
0
 

Author Comment

by:mytilig
ID: 16440600
Hello all,
Thanks for all the time.

I removed all the loggers and found that my request.getParameter() seems to be fine and bringing in all the data.

I realize I am dealing with 2 separate issues here.
1. Logger cannot handle data larger than 7k
This is the reason I was getting all the errors I mention above.  so I have removed all the loggers from my code.

2. My main problem -- because of which I started the logging :(
My JVM does not seem to be able to handle when the string size exceeds 7k
My JSP code is

String temp = request.getParameter("ip");
emp.setDevTxt(temp);

emp.setDevTxt(temp) is the line that throws null pointer exception.

Xmx  is set to 1G, but not sure why the webserver still cannot handle string >7k

This is what I have so far.
0
 
LVL 28

Expert Comment

by:rrz
ID: 16441403
Did you tell us what web app server you are using yet ? I can't see that post.  Which version of java ? Describe anything else that may shed some light on your problem.  I can't reproduce your problem here.  So the logger is out of the way ?  
>emp.setDevTxt(temp) is the line that throws null pointer exception.
Are you sure the parameter is being sent ?  Did you try borislavmarkov's suggestion ?     rrz
0
 

Author Comment

by:mytilig
ID: 16441609
Im sorry didnt mention webserver

SunOne 6.1
Solaris 5.9
Jdk 1.4.2_06

Yes the parameter is being set because it works for strings lesser than 7000 characters.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16441665
what does:

    emp.setDevTxt

do?

Java 1.4.2 doesn't have any problems with 7k strings...

You could try 1.4.2_10 (the latest) to be sure...?
0
 
LVL 28

Expert Comment

by:rrz
ID: 16441771
>Yes the parameter is being set because it works for strings lesser than 7000 characters.
That is good logic. I think that why bris suggest what he did.  Do you need help implementing it ?  

Hi Tim, isn't it past your bed time ?  Good idea anyway.
He should first try it the way we did in your posts. If that works, then we must look at the code in "emp".
0
 

Author Comment

by:mytilig
ID: 16441841
YEs I tried request.getInputStream()  too and same issues.

(I thought I posted the result earlier, but apparently not)

The problem DOES NOT happen on my local SunOne webserver running on windows.
It happens on both my solaris machines that have SunOne webserver running.  It is the same code I am deploying to all 3 servers.

All javas are 1.4.2


Any known bug with java 1.4 build on solaris causing the issue?

emp.setDevTxt is just a bean class that has setter tag

      public void setDevPlanTxt1(StringBuffer devPlanTxt1) {
            this.devPlanTxt1 = devPlanTxt1;
      }

--Mythili (she)
0
 
LVL 28

Expert Comment

by:rrz
ID: 16442240
>YEs I tried request.getInputStream()  too and same issues.
Could you elaborate ?   Did you send the request from a HTML page as I did above ?
When the request body exceeds 7000 characters , then suddenly it is null ?  So problem is before it reaches the JSP ?
0
 
LVL 2

Expert Comment

by:borislavmarkov
ID: 16443101
I said I tried "request.getInputStream()" on jetty, not on SunOne, the author had not yet mentioned his environment.
Anyway, I suggest to change the encode type of your request.
in HTML please change enctype

<html action="..." enctype=".."> search for a better enctype and let's see how your request is handled.

Try with another enctype like:

ENCTYPE = "multipart/form-data" | "application/x-www-form-urlencoded"

0
 
LVL 35

Expert Comment

by:TimYates
ID: 16443294
mytilig, does the simple JSP here: http:Q_21810424.html#16434015  Work or not?
0
 

Author Comment

by:mytilig
ID: 16493877
Answering my own question here:
My code worked fine after increase the StackSize variable in magnus.conf
Thankyou all.
0
 
LVL 28

Expert Comment

by:rrz
ID: 16493892
Good, then ask for this to be deleted.  
0
 

Author Comment

by:mytilig
ID: 16502199
No why should it be deleted?
Number of people have provided inputs and spent lot of time to help on this. Maybe some of the suggestions may help someone else.
Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

830 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