• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Redirect to .jsp Spring MVC

 
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to redirect from a Servlet to a .jsp page, using Spring MVC. It doesnt find the resource:



The code of the Servlet is like this:



I see that it doesnt find the file, the .jsp file is in the WEB-INF and in the jsp folder the Servlet is in a source package.

Any guide of how to write the rigth path, please?

Regards, Isaac
 
Greenhorn
Posts: 11
Angular Framework Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're not using any Spring in your servlet...


This is a very simple example with Spring


 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying your redirection example, my code is like looks here:

index.jsp





Servlet



After pressing a button in the form I get the next error:



Any idea, please?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring has its own front controller DispatcherServlet thing.

How are you setting up your web.xml?
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is the default one:



First it goes to

redirect.jsp

and from there to

index.jsp





Any idea, please?
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web.xml looks ok.

Have you mapped the view resolvers in the spring's config file? The resolver should look something like:



Also in your so called Servlet, you ought to tell Spring its existence by making it a Spring controller using @Controller when declaring the class.

Have a look at Spring MVC page
 
Angus Ferguson
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have in my Spring config file:



In the class I added the controller anotation



I still get the same 404 error, it is like

@RequestMapping("/redirect.do")

would not make any sense.

Any idea, please?
 
reply
    Bookmark Topic Watch Topic
  • New Topic