• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Integarting existing jsps and Servlets Web Application with Spring 3.0

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are using Servlets and JSps as our Front End , and we want to use Spring
In order to achive Application context in my web layer , using



Do i need to write this piece of code in each of my servlet .

Or i shall make a Filter and mention this code there ??

Please suggets . Thanks .

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's unfortunate that you're not taking advantage of Spring MVC or Spring Webflow.... but if you truly want to be on the route of "Servlets & JSP" then I would create a Abstract Class that your servlet extends. In that Abstract class, you'll have a method like Object getBean(String beanName). Of course, your abstract class will extend the httpservlet. Again, if you could have a choice to use any MVC framework...I strongly recommend that approach...
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Won Cho , thanks for the suggestions , but

It's unfortunate that you're not taking advantage of Spring MVC or Spring Webflow.



I agree with you on this , but ours is a legacy Application (developed since 2004 ) , so we want to keep our Existing functionality working .

then I would create a Abstract Class that your servlet extends. In that Abstract class, you'll have a method like Object getBean(String beanName).



What advantage i get from this , i am thinking of writing a simple class (A factory class ) , which will be responsible to return the ApplicationContext using WebApplicationContextUtils.getWebApplicationContext(getServletContext());

What do you suggest ?? please advice . Thanks .
 
Ranch Hand
Posts: 57
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi Kiran Va wrote:

then I would create a Abstract Class that your servlet extends. In that Abstract class, you'll have a method like Object getBean(String beanName).



What advantage i get from this , i am thinking of writing a simple class (A factory class ) , which will be responsible to return the ApplicationContext using WebApplicationContextUtils.getWebApplicationContext(getServletContext());

What do you suggest ?? please advice . Thanks .



Having both are good. With the Abstract servlet class and inherrited getBean method, you don't need to pass the ServletContext instance as argument. You can also use your factory class to serve more than just servlet, but also tags, filter...
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Having both are good. With the Abstract servlet class and inherrited getBean method, you don't need to pass the ServletContext instance as argument.


Agreed , and good approach also . Thanks .
 
Won Cho
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I said before, I'd still consider converting that into Spring MVC. All that servlet is doing is processing doget or dopost with httprequest and httpresponse. You can easily convert that into Spring MVC @Controller and @RequestMapping feature. I think once you convert 1 servlet, all the remaining would be just repeated process. It maybe worth your time to evaluate how much effort is needed to convert your servlets. My guess is less than 1 hour for the first one and probably 15~30 min for the rest.
 
Won Cho
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many features for Spring MVC but just having automated testing for @Controller should be more than enough reason to change... I'm guessing that there is no automated testing for your servlets.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic