• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Controller is calling every action twice; therefore form is getting submitted twice.

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've been facing following issue in my project:
Controller is calling every action twice; therefore form is getting submitted twice.

I'm using spring mvc 3.

I's quite strange till yesterday code was running fine and suddenly I've started facing this issue.

Any suggestions/corrections are welcome.

Thanks.
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone to help on this please, something urgent and I'm not able to resolve. so..
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to post more information

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to post more information

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What changed?

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What changed?

Mark
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for your interest.

As far as I remember there nothing which changed drastically except an addition of one mapping.

Really know way to understand why controller is calling every mapping twice.
Is is something already faced in spring? I saw few posts on spring-forum n there it was happening because of empty img tag like .
I checked all my jsp pages n didn't find such an occurrence.

Thanks,
Mahesh
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt it has to do with an image.

Anyway, we really can't be of any help without more information/code. We can't see what mappings you have, what your configuration is? Maybe you have two equal mappings.

Mark
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, controller is calling every mapping twice it's not for a particular mapping that it's happening. So I've doubt whether it is something related to configuration.
I've two kind of url mappings so one is for /admin and one for /user.

Therefore I'm having two servlet-config files one is for /admin and /user and two servlets have been configured as follows.

<servlet>
<servlet-name>mvc-admin</servlet-name>
<servlet-class>com.myapp.servlets.AdminServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet>
<servlet-name>mvc-user</servlet-name>
<servlet-class>com.myapp.servlets.userServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

and have two controller one is adminController and other is userController.

and have mappings as follows:
in adminController:
@RequestMapping("/selectUser")
public ModelAndView admin(){
return new ModelAndView("/admin/getapplist","list", Application.getApplicationList());
}
in userController:
@RequestMapping("/showlist")
public ModelAndView user(UserForm form, ServletRequest request) {
ModelAndView modelAndView = new ModelAndView("/user/showlist");
modelAndView.addObject("list", Application.getApplicationList());

return modelAndView;
}
Thanks.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Huh, where in Spring MVC do you have to create your own servlets? Spring MVC uses just one servlet the DispatcherServlet.

I highly recommend reading the Core Spring documentation, in the section on Spring MVC. Right now, you are over-complicating things and adding things that shouldn't be there, and therefore all bets are off of anything working in that environment.

Or here is a well written simple tutorial just to make one simple Controller with all configuration.

http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example/

Mark
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for assistance Mark, issue is resolved now.
Root cause was I'd written a filter which was calling doFilter twice.

Thanks again,
Mahesh
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mahesh Bamane wrote:Thanks for assistance Mark, issue is resolved now.
Root cause was I'd written a filter which was calling doFilter twice.

Thanks again,
Mahesh



Cool.

Still don't understand why you have those two servlets, but at least your issue is resolved.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic