aspose file tools*
The moose likes Spring and the fly likes Spring Basic Hello World Program not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Basic Hello World Program not working " Watch "Spring Basic Hello World Program not working " New topic
Author

Spring Basic Hello World Program not working

Maya sekar
Ranch Hand

Joined: Sep 22, 2011
Posts: 70
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

Joined: Sep 22, 2011
Posts: 70
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Maybe, and I might be wrong, because your servlet mapping is

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Maya sekar
Ranch Hand

Joined: Sep 22, 2011
Posts: 70
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
Raghvendra Pratap Singh
Greenhorn

Joined: Jul 26, 2012
Posts: 22

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 ?


Thanks and Regards, Raghvendra Pratap Singh
"Quality means doing it right when no one is looking"
Maya sekar
Ranch Hand

Joined: Sep 22, 2011
Posts: 70
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
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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

Joined: Sep 22, 2011
Posts: 70
Thanks guys
I guess i'll mark this as resolved then...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring Basic Hello World Program not working