1

I am having problem in some request access, in my web application. I am not able to figure out the issue.

In my we application servlet mapping configuration is like this..

 <servlet>
     <servlet-name>default</servlet-name>
     <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
     <load-on-startup>0</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

and the spring configuration for dispatcher servlet is like this.

In WebApplicationInitializerConfig

AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
        dispatcherContext.register(DispatcherConfig.class);

        DispatcherServlet dispatcherServlet = new DispatcherServlet(dispatcherContext);
        ServletRegistration.Dynamic dispatcher;

        dispatcher = servletContext.addServlet("api/", dispatcherServlet);
        dispatcher.setLoadOnStartup(1);


        String apiMappingPath = /api/*;

        dispatcher.addMapping(apiMappingPath);

When I make some API request, the call goes to the method and method sout also print in server log.But no response comes out.

For information I am deploying the application on glassfish server.

I am not able to get the issue reason also. If any one knows then help me out.

Method code:

 @RequestMapping(value = "/email", method = RequestMethod.POST)
    public Map passwordResetMail(@RequestBody(required = false) String email, HttpServletRequest request, HttpServletResponse response) {

        system.out.println("email"+email);
            Map map = new HashMap();
           map.put("email",email);
          return map;
}
Anita
  • 2,352
  • 2
  • 19
  • 30
  • Please show the method – dotvav Aug 03 '15 at 07:30
  • @dotvav I have added method code. – Anita Aug 03 '15 at 07:39
  • So you see the `"email"+email` printed in the server `system out` but you don't see it in the response? Do you get any response at all? Response code? – yair Aug 03 '15 at 09:08
  • no I don't get any response. the request status shows pending – Anita Aug 03 '15 at 09:32
  • What kind of output do you expect? Are you expecting to see a web page or for the server to send some kind of AJAX (XML/ JSON, etc.) response to the client? – manish Aug 03 '15 at 15:32
  • in console I am getting pending for the request. I just want this call to finish . It should give json response – Anita Aug 03 '15 at 15:36
  • Which console are you referring to - browser console, IDE console, command-line console? What is the exact message on the server-side? From your post it seems like the server-side is just fine (because you have said that you can see the `System.out.println` message. Returning a `Map` from a controller method is the same as returning a `ModelAndView`, with the view name being the same as the URI (`email`) in your case. Do read the Spring MVC documentation to understand how to return JSON output from the controller. – manish Aug 04 '15 at 09:22
  • I think the problem lies in response from controller to ui through different filters. BTW it is working in some condition and in some condition it fails. and console means browser console – Anita Aug 04 '15 at 09:43

0 Answers0