This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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

Problem finding index page under WEB-INF / Spring MVC

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to move all my jsps into a folder under WebContents/WEB-INF/view but I keep getting a 404. Going to http://localhost:8080/test-app/ doesn't find my index.jsp under the view folder, but is ok in the WebContent folder. Why might this be?

Folder structure:


dispatcher-servlet.xml



web.xml

 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

You should try...
http://localhost:8080/test-app/index it won't find an index.jsp file if you are only pointing at the root...

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Clark wrote:Hey,

You should try...
http://localhost:8080/test-app/index it won't find an index.jsp file if you are only pointing at the root...

Sean



That doesn't work either.
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, folders under WEB-INF are protected and must be accessed via code.

http://stackoverflow.com/questions/4688841/http-404-problem-jsp-can-not-see-in-web
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

That shouldn't matter, that's why you have created a viewResolver in your spring configuration and why you have used the <mvc:view-controller /> annotation.
There is however another problem in your configuration that is probably the issue, you have not created Spring's servlet in the web.xml you posted. Therefore Spring will never be initialised.

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Clark wrote:Hey,

That shouldn't matter, that's why you have created a viewResolver in your spring configuration and why you have used the <mvc:view-controller /> annotation.
There is however another problem in your configuration that is probably the issue, you have not created Spring's servlet in the web.xml you posted. Therefore Spring will never be initialised.

Sean



Hey,

I appreciate your help, I updated my code in the first post.

<mvc:view-controller /> - I use this tag because I used this on placement this summer, and I thought I'd use it again, but I can't seem to set up the application properly with Tomcat, before, I was using Google App Engine.

If I go to my index.jsp by going to http://localhost:8080/test-app/ I get a 404 (Going to http://localhost:8080/ gets me the Tomcat management page).
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

The URL pattern for the servlet is still wrong, it should go from the context root (test-app) so it should be /*.

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Clark wrote:Hey,

The URL pattern for the servlet is still wrong, it should go from the context root (test-app) so it should be /*.

Sean



Still doesn't work.
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok got it, should be / and not /*.

I just created a test app with your settings (apart from the sitemesh filter which I commented out and the listener which I did the same as it expects an applicationContext.xml file).

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Clark wrote:Ok got it, should be / and not /*.

I just created a test app with your settings (apart from the sitemesh filter which I commented out and the listener which I did the same as it expects an applicationContext.xml file).

Sean



Tried / and not /*, and commented out the sitemesh, restarted the server too. I'm using Tomcat 7, using the Tomcat installaion in Eclipse.

Edit:
Can you upload your test app for me to test please?
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What url are you using?

Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Clark wrote:What url are you using?

Sean



http://localhost:8080/test-app/
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm out of ideas then, it's certainly working from mine.
Just make sure there are no errors coming up when tomcat starts.

Sorry.
Sean
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved.
 
Mike Gibbs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we use mvc:view-controller tag for displaying a tiles view.
Eg:If we have a tiles definition of the form <definition name="userLogon.page" template="webapp/app/layout/baseLayoutExterior.jsp" extends="basePageDefinition">
Can we write <mvc:view-controller path="/logon" view-name="userLogon.page"/> in our servlet.xml file.
I am getting an HTTP 404 RESOURCE NOT FOUND ERROR on this whereas a normal hello.jsp page is displayed without problems.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic