aspose file tools*
The moose likes Servlets and the fly likes getParameter() limit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getParameter() limit" Watch "getParameter() limit" New topic
Author

getParameter() limit

Patrick McDowell
Greenhorn

Joined: Aug 15, 2000
Posts: 4
I'm need some help retrieving a large string from a TEXT AREA to be inserted into a CLOB. Everything works fine in my code until my byte[] reachs a length of 8509. Any bigger than that and I get an ArrayIndexOutOfBounds Exception. I have read that the max length of an array is around 65K since Java uses an integer to index an array.
So my question: Is the req.getParameter method limited in the size of String it can retrieve from a form?
Any help wouold be greatly appreciated.
Below is the code snippet I'm using in a servlet that is called when my form is submitted:
String body = req.getParameter("body");
Clob quoteBodyClob = null;
stmt3 = con.createStatement();
con.setAutoCommit(false);
rs3 = stmt3.executeQuery("SELECT BODY FROM CLOBNEWS
WHERE ITEMID =" + nextItemID + " FOR UPDATE OF BODY ");

while(rs3.next())
{
quoteBodyClob = rs3.getClob("BODY");
}
OutputStream os=
((oracle.sql.CLOB)quoteBodyClob).getAsciiOutputStream();
byte[] b = body.getBytes("ASCII");
os.write(b);
os.flush();
os.close();
PreparedStatement pstmt = con.prepareStatement(
"UPDATE CLOBNEWS SET BODY = ? WHERE ITEMID = " + nextItemID);
pstmt.setClob(5, quoteBodyClob);
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
dear friend,
i am not able to understand your code as i don't know about Clob and all.but anyhow i catch up your problem.
what is the method by which you are posting that large content?
if it is GET method,we can't pass large data contents.so it is better to use POST method for posting.
expecting your reply,
with regards
balraj
Patrick McDowell
Greenhorn

Joined: Aug 15, 2000
Posts: 4
Thanks for your response. I'm currently using POST for my method. Is there a maximum amount of data that can be passed with this method?
Thanks again.
Mohammed Dohad
Greenhorn

Joined: Sep 28, 2000
Posts: 2
Hi Patrick,
Well I tried to accept data from an HTML page using a servlet with post method and it worked really well, I was able to receive all 9kb of it!! In yor case, I guess there is a problem with the page size of input buffer at the server-side.
Here is the code that I had used for your reference :-
public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException
{
String data = req.getParameter("data");
PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter("Data.txt")));
file.println(data);
file.close();
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML><BODY><H1>Data used successfully</H1></BODY></HTML>");
}

[This message has been edited by Mohammed Dohad (edited September 28, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getParameter() limit