File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes OutOfMemory Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "OutOfMemory Error" Watch "OutOfMemory Error" New topic

OutOfMemory Error

Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
I have a servlet
package servlet;
import DBAccess.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.servlet.*;
import javax.naming.*;
import javax.servlet.http.*;
public class insertBusinessUnit extends HttpServlet
boolean p = false;
/*char squote ='\'' ;
char dquote ='\'' ;*/

public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
String BusinessUnit = request.getParameter("businessunit");
String Description = request.getParameter("description");
ProjectDatabase db = new ProjectDatabase();
/*String bunit =db.changeBusinessQuote(BusinessUnit,squote,dquote);
p = db.createBusinessUnit(BusinessUnit,Description); out = response.getWriter();
if (p)
response.setContentType( "text/html" );
out.println( "<html><head><title>IT Architecture Documentation System</title></head>" );
out.println( "<body>" );
out.println("Information is added sucessfully");
out.println( "</body></html>");
response.setContentType( "text/html" );
out.println( "<html><head><title>IT Architecture Documentation System</title></head>" );
out.println( "<body>" );
out.println("Information is not added");
out.println( "</body></html>");
this servelet calls a method from ProjectDatbase class
/*public String changeBusinessQuote(String BusinessUnit, char squote, char dquote)
StringBuffer buf = new StringBuffer (BusinessUnit);
for (int i = 0; i < buf.length(); i++)
if (buf.charAt (i) == squote)
buf.append (dquote);
return buf.toString();

The problem is if i take the comments out from the servlet and this method, i get this error
Root cause of ServletException
<<no stack trace available>>
if it has comments then it works fine, plz help.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm thinking you are producing an infinite loop...

Your loop exit condition is i< buf.length(), but you are constantly changing (increasing) the value of buf's length within the loop.

If you simply want to change single quotes to double quotes:
I agree. Here's the link:
subject: OutOfMemory Error
It's not a secret anymore!