• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Spring Basic Hello World Program not working

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys

I was trying out a Spring MVC 3 Hello World Program. After innumerable failed attempts I simply decided to download a sample code from online and run it. And that too has failed

I downloaded the code from the link at the botton so the code is pretty much the same...

http://viralpatel.net/blogs/spring-3-mvc-create-hello-world-application-spring-3-mvc/

My web.xml




spring-servelt.xml



Controller Class



index.jps



hello.jsp




I have attached my directory structure as an image file in case you want to refer that too....
When I do run the program in Apache Tomcat, I get the index page as I should, but when I click on the SAy Hello link, I get a requested resource is not available error.... And the program doesn't print the "Hello am inside spring" or the "Hello World, Spring 3.0!" message as it should in the console.


Please help, I have been at it all day long....
Thanks a lot
Have a nice day

 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Update:
Hey

So I asked a friend of mine and he messed around with it a bit.
When we run the program, the index.jsp page opens just fine in the browser

http://localhost:9090/Spring3MVC/index

... But it does not get successfully redirected to the hello.jsp page.

http://localhost:9090/Spring3MVC/hello

WE don't understand why...
but when we did try this, http://localhost:9090/Spring3MVC/hello.html the program works fine.... ( though http://localhost:9090/Spring3MVC/hello.jsp doesn't work )

So I was told Spring encounters a bit of trouble when it tries to convert my jsp to htlm files... I am a beginner and I don't understand what that means.... What should I do to fix it?
Thanks
Have a nice day
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe, and I might be wrong, because your servlet mapping is

<url-pattern>*.html</url-pattern>

Mark
 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Maybe, and I might be wrong, because your servlet mapping is

<url-pattern>*.html</url-pattern>

Mark



Hey Mark .

Thank you for taking the time to read and respond... I took your suggestion and removed .html extension from the url-pattern, leaving only


But sadly that did not work either... The browser couldn't find the index.jsp page.

Thank you so much for trying to help...
Have a nice day
 
Greenhorn
Posts: 22
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maya ,
You can do two things

1. Either You remove *.html to *


or
2. On your controller you can have


@Maya

Sorry but just want to confirm , Have you put your index.jsp page outside the WEB-INF folder ?

 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raghvendra,

I did try replacing the *.html with *. But that does not work. On the other hand, replacing *.html with simply / does work. Though I still don't understand what all of this means.
Adding hello.html in the Request Mapping doesn't work either....

Thank you so much for taking the time to reply...
Have a nice day
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry Maya. I always misunderstand just * versus say / or /*

I never know when it needs a / or not.

Crazy stuff. That is why when I get it working once somewhere, I always copy and paste it into newer projects.

Mark
 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys
I guess i'll mark this as resolved then...
 
mooooooo ..... tiny ad ....
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
    Bookmark Topic Watch Topic
  • New Topic