my dog learned polymorphism*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "OutOfMemory Error" Watch "OutOfMemory Error" New topic
Author

OutOfMemory Error

Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
I have a servlet
package servlet;
import java.io.*;
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);
System.out.println(bunit);*/
p = db.createBusinessUnit(BusinessUnit,Description);
java.io.PrintWriter 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>");
}
else
{
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>");
}
out.close();
}
}
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
java.lang.OutOfMemoryError
<<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: http://aspose.com/file-tools
 
subject: OutOfMemory Error