• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Page not Loading after POST action

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello JavaRanch, I dont know if this is the right thread where I should post my concern, I've been searching the categories, but I think this is the closest.
Anyway, I'm a total beginner in Spring MVC development, so I'm having a little struggle deploying my simple web-app. Please bare with me..

The thing in here is, I cannot see why my result(result.jsp) page doesn't load after I press the submit button on my first page(Student.html)
here are the codes for my simple program.


The controller class (StudentController)


the Student class


the student.jsp


the result.jsp


the servlet (HelloStudent-servlet)


and finally the web.xml


so far I can successfully load the first page (student.html)
as http://localhost:8080/HelloStudent/student.html (just to show the URL)
but as I press the submit button, I always get Error 404
and the url displays as http://localhost:8080/HelloStudent/addStudent (here i expect the result.html)
I wonder what conflicts my POST method in my controller class has with my result.jsp page or any codes in my project.
Please bare with me, I'm really new to Spring Development, I just finished a tutorial with basic development in swing. Any help would greatly appreciated, thank you. :)


edit Just like to mention, this is a part of the tutorial I found on web. I just learned something with my POST request method
I'm having a hard time finding a very good sample(a working sample in my case) that will show me how to map my form into my POST method that will load my result page..
 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mechanically, check



with your



Your MVC servlet dispatcher will process only url that end with .html

A quick test will be rewrite the url mapping:


 
Jeffrey Santos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the help , but I encountered the first problem before having this one, a "404 error" ,

Warning: No mapping found for HTTP request with URI [/HelloStudent/] in DispatcherServlet with name 'dispatcher'

, after I deploy and run the project, this is the output URL http://localhost:8080/HelloStudent and I get the 404, but when I manually put the student in the URLhttp://localhost:8080/HelloStudent/student, It runs perfectly fine, I even resolved my problem with loading the result page(thank you for helping me with that)

As I search the forum I ran across some posts around that could match my problem, some of the post says that It could or It is a build & environment issue, well in my case I'm developing this simple project in Netbeans 8, Glassfish 4 and Spring 4. If not too much, would you point me in the right direction? I've been searching and searching some introductions/samples in the Google, but I always end up having issues, Error 404, Bad requests etc.., I cant find something that will run perfectly and from there, I can understand and learn ste-by-step whats going on. Another thing I want to ask if any error would have something to do with version? I cant find any sample codes with the latest frameworks(e.g Spring 4.0.1) and some latest tools(Glassfish 4). I use to see, Spring 3, and Glassfish 3 below sample codes.

I changed my url-pattern with this one, but still no luck.



dir.png
[Thumbnail for dir.png]
My directory structure.
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me recap if I understanding correctly from what you wrote:

1. http://localhost:8080/HelloStudent/student is working
2. Form submission is working
3. http://localhost:8080/HelloStudent is not working as you expected.

What is the result/output you expect according to your understanding?
 
Jeffrey Santos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm expecting that this url http://localhost:8080/HelloStudent, when it appears on my browser, the page will load fine(as indicated on the tutorial I'm reading), but when it loads a URL that way, it gives me a 404, so im adding a "student" in the browser's URL then it works fine, what Im expecting that it should load right after I run it , not when I put a "student" in the browser's url
 
Jeffrey Santos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after a painstakingly searching(with no luck) , and randomly shoot a bullet, I manage to resolve the problem in deploying-->run the first page

i changed my mapping value, from


into



I'm searching the google to understand why I need to map my value into a simple "/" to deploy and run my project, but still no luck, I don't see any example with a mapping value like this, hope anyone could enlighten me.
 
H Paul
Ranch Hand
Posts: 491
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the doc on Spring MVC version 4.x for example OR the version you're using

16.3 Implementing Controllers
Mapping Requests With @RequestMapping
Defining @RequestMapping handler methods





B. In your log.xml, put this. You will see what URL maps to what what handler method



C. GOOD LUCK :-D
 
Jeffrey Santos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
finally, now I know where to continue or start all over again in my introduction-to-spring, and thanks for telling me about defining a bean for logging, It will be a great of use, and I just found a full documentation of Spring 4.0 Spring 4 Documentation, thanks again
 
H Paul
Ranch Hand
Posts: 491
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Spring website:

Download this STS eclipse-based ide from Spring
http://spring.io/tools/sts/all

Many Spring and type of application examples:
http://spring.io/guides
 
Jeffrey Santos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANKS again! , actually a while ago, I also searched about IDEs, especially on spring development, majority of my search suggest Spring Tool Suite, maybe this might put me away on any deployment issues in developing Spring apps, thanks a lot! God bless
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!