• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

getParameter() limit

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
He does not suffer fools gladly. But this tiny ad does:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic