Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:57:37+00:00 2026-06-01T12:57:37+00:00

In my servlet I have the following code: response.setContentType(application/json);//set json content type PrintWriter out

  • 0

In my servlet I have the following code:

    response.setContentType("application/json");//set json content type
    PrintWriter out = response.getWriter();

   EntityManagerFactory emf=Persistence.createEntityManagerFactory("webPU");
   GpsJpaController gjc=new GpsJpaController(emf);    
   java.util.List<Gps> listGps=gjc.findGpsEntities();//retrieve the list of GPS from DB 

   Gson gson=new Gson();
   String json=gson.toJson(listGps); //convert List<Gps> to json
   out.println(json);

response is returned from ajax with this code:

$.ajax({ 
           type: "GET", 
           url: "getInfoGeoActive",
           dataType: 'json',
           error: function(xhr, ajaxOptions, thrownError){ $("#content").empty().append("* Error from server cause: "+thrownError).addClass("error"); } ,
           success:function(data){$("#content").empty().append(data);}
             });

when I run the code I still receive the following error(from ajax):

  Error from server cause:Internal Servlet Error

I also tried to display the serialized object List<Gps> in the same java page without ajax, as follows:

EntityManagerFactory emf=Persistence.createEntityManagerFactory("JavaApplication21PU");
        GpsJpaController gjc=new GpsJpaController(emf);
        java.util.List<Gps> listGps=gjc.findGpsEntities();

        Gson gson=new Gson();
        String json=gson.toJson(listGps);

        System.out.println(json);

I get this Error:

Exception in thread "main" java.lang.StackOverflowError
    at java.lang.StrictMath.floorOrCeil(StrictMath.java:355)
    at java.lang.StrictMath.floor(StrictMath.java:340)
    at java.lang.Math.floor(Math.java:424)
    at sun.misc.FloatingDecimal.dtoa(FloatingDecimal.java:620)
    at sun.misc.FloatingDecimal.<init>(FloatingDecimal.java:459)
    at java.lang.Double.toString(Double.java:196)
    at java.lang.Double.toString(Double.java:633)
    at com.google.gson.stream.JsonWriter.value(JsonWriter.java:441)
    at com.google.gson.Gson$4.write(Gson.java:270)
    at com.google.gson.Gson$4.write(Gson.java:255)

Please Help!

EDIT:
the final solution of this problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:57:39+00:00Added an answer on June 1, 2026 at 12:57 pm

    StackOverflowException occurs due to infinite recursion. You may need to check the code thoroughly for any unintended recursion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following servlet code public void doPost(HttpServletRequest request, HttpServletResponse response){ Backup bup
I have the following JSP File and Servlet file <html> <head> <meta http-equiv=Content-Type content=text/html;
I have following architecture in my application. Client (GWT) <--calls--> Servlet <--calls--> Service <--calls-->
If I have the following code in a servlet: Properties p = new Properties();
I have to pass parametrs From servlet to jsp .Iam using the following code.Is
I have the following code in Perl which posts to my HTTP Servlet, calling
I have the following in my dispatcher-servlet.xml <?xml version=1.0 encoding=UTF-8?> <beans xmlns=http://www.springframework.org/schema/beans xmlns:mvc=http://www.springframework.org/schema/mvc xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
I have the following code... @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
In a ViewHandlerWrapper-implementation I have following code: public void renderView(FacesContext context, UIViewRoot viewToRender) throws
Sorry about the vague title but I have a servlet with the following mapping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.