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 9080201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:01:25+00:00 2026-06-16T20:01:25+00:00

In the jsp i am passing the data as json,as in the controller method

  • 0
    In the jsp i am passing the data as json,as in the controller method i am trying to map the data to  Personbean object using @RequestMapping. But its throwing an exception.

@ResponseBody is working fine, if i remove the @ResponseBody code.
Please suggest what am i doing wrong?
I have pasted the code for reference.

//jsp    (added the data as json and also content type)
    <script>
        function abc(){
            alert('here!!');



            $.ajax({
                url:'anki',
                type:'GET',
                data:({name:"me"}),
                dataType: 'json',
                contentType: 'application/json',    
                success:function(data){
                alert('here gain');

                 $('#time').html(data.name);


            }
            });
        }
        </script>
    <input type="button" name="submit" title="submit" onclick="abc()"/>
    <div id="time"></div>


//PersonBean (Bean class)

package com.controller;

public class Personbean {
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


}

    // controller method

//(Trying to use both @ResponseBody and @RequestBody in this method)

    @RequestMapping(value="/anki",method=RequestMethod.GET)
        public @ResponseBody EmployeeBean hhh(@RequestBody Personbean pb){
            System.out.println(pb.getName());
            System.out.println("new method");
            EmployeeBean e=new EmployeeBean();
            e.setId("1001");
            e.setName("ankita");
            return e;
        }

//i have added the "jacksonMessageConverter" in the dispatcher servlet

    //dispatcher servlet

    <bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
     <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
      <list>
        <ref bean="jacksonMessageConverter"/>
         </list>
    </property>



//Exception stacktrace(For reference)

    java.io.EOFException: No content to map to Object due to end of input
        at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2444)
        at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2396)
        at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1662)
        at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:124)
        at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:154)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.readWithMessageConverters(HandlerMethodInvoker.java:633)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestBody(HandlerMethodInvoker.java:597)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:346)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
  • 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-16T20:01:26+00:00Added an answer on June 16, 2026 at 8:01 pm

    Try this

            $.ajax({
            url:'anki',
            type:'POST',
            data:JSON.stringify(eval({"name":"me"})),
            dataType: 'json',
            contentType: 'application/json',    
            success:function(data){
            alert('here gain');
    
           //  $('#time').html(data.name);
    
    
        }
        });
    

    Dont forget to change the Method to POST in your controller

    method=RequestMethod.POST 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing the following JSON object from a .jsp page to a java
I am passing dynamic values with href tag in dynamically generated jnlp using jsp.
I am calling a JSP by passing parameters which outputs a valid JSON as
I am passing data to my servlet through the jsp in this way: <a
I am trying to use jstl, but on my web page, its not really
Is there any way of passing data to JAVA class from a JSP page
I have this code snippet where I am passing data to another jsp file.
From jsp through ajax cal I'm passing json string to server and I am
I have an html/jsp form that I am serializing(using jquery) and passing to a
Hi I am following Passing parameters from JSP to Controller in Spring MVC obviously

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.