• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

SimpleFormController - form:form action URL points to formView in stead of the URL

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I'm new to Spring and i'm trying to implement a SimpleFormController and a form with the spring-form tag library. I have a DAO bean and an command object with the fields of the form. I also extended the SimpleFormController:


And the jsp formView


I have defined this form controller in the dispatcher-servlet.xml


When i try this form i get the following message from the glassfish server:

HTTP Status 404 -

type Status report

message

descriptionThe requested resource () is not available.

Sun GlassFish Enterprise Server v2.1.1



And if i look at the generated form HTML code i see:


Why is it refering to "/logintest/WEB-INF/jsp/testForm.jsp" and not to "/logintest/testform.htm" (the mapping of the controller)? is it something i missed in the documentation or something i should know about spring? The only reference to this issue i found using google is refering to Spring 2.0 and not giving a cause or solution. I am using Spring 2.5 (the one supplied with netbeans 6.7.1).

Can anyone point me to the right direction?
 
Gert Jan Kruizinga
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course i can set the "action" property of the <form:form> tag to the right URL but shouldn't the formController or the tag library do that for me?
 
Gert Jan Kruizinga
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i literally copy the Spring SimpleFromController example from vaannila.com (http://www.vaannila.com/spring/spring-simple-form-controller-1.html) i experience the same problem, the action from the form points to the view jsp and not to the form controller.

(html send to browser)
<form id="user" method="POST" action="/formtest/WEB-INF/jsp/userForm.jsp">

which results in a 404 message in the browser. Am i the only one experiencing this problem? then there should be something wrong with my configuration. Who can help me find out what i do wrong? i assume that the people from vaannila have tested there examples before publishing.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Gert-Jan,

works fine if you change your config a little: see below
Hope this works for you!

Herman

 
Gert Jan Kruizinga
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Herman,

Thank you for your support but it is not working, the action tag in the form is still pointing to de "WEB-INF/jsp/testForm.jsp" in stead of the current page. I have googled a litle further on this issue ad therefor i want to ask you on which IDE and application server you tried it? it seems that this issue appears om the glassfish server which came with Netbeans 6.7.1, i found at least 2 others with the same issue and who are using the same IDE.

What i see is when i request for "http://localhost:8080/logintest/index.htm" that the form generated has the following request properties:
JSP Request Method: GET
Request URI: /logintest/WEB-INF/jsp/testForm.jsp
Request Protocol: HTTP/1.1
Servlet path: /WEB-INF/jsp/testForm.jsp
Path info: null
Query string: null
Content length: -1
Content type: null
Server name: localhost
Server port: 8080
Remote user: null
Remote address: 127.0.0.1
Remote host: 127.0.0.1
Authorization scheme: null
Locale: nl_NL


And as you can see in the source of the form:form tag the action attribute is extracted from the requestURI parameter. So assuming that glassfish is the reference implementation and the guys at spring are no idiots i assume that i must do something wrong, or is this a bug/feature?
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I used Netbeans 6.8 as IDE, it comes with GlassFish v3 Domain and Tomcat 6.0.20. Both servers have to result here.

with the configuration that I used, the form tag looks like <form id="editRelatie" method="post" action="/WebApplication1/index.htm">
(you probably have a different context root)

Did you find anything in your logfiles or console?

Herman

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem with my source code.
When I click to the submit button in form view, it will submit to the formview itself, not the controller as I expected.
Here is my dispatcher-servlet.xml

and here is enterNameController.java

and here is the formview

when this jsp file rendered to HTML, it looks like


when i really want the action will be /spring_sayhello/enterName.htm ( the controller)

I use Netbeans 6.5.1 with Spring 2.5
What should I do ?
reply
    Bookmark Topic Watch Topic
  • New Topic