This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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

Questions about Spring 2.5 and Java 6

 
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I’m going to start writing my application for athletes based on Spring 2.5.6 and Java 6 (as I’ve read that Java 7 is less compatibile with this Spring version). I’ve couple of questions as I’m not familiar with such an old versions. (I need to write it for my Engineer’s Thesis – comparing app written in old version of Spring and in newest version of Sping Boot)  

1. I know already I need web.xml, but do I need servlets  to handle http requests or there is some other common way to do it? I won’t have any front sides (like jsp files) – just backend.
I mean, I want to build the most common app based on Spring 2.5 and java 6 and to do it I need these two things to do any request, right?

2. What about declaring beans in these versions. Do I need to do it in xml like <bean>….</bean> or I can annotate class with for example @Component (as @Service propably does not exist in this version). Which way should I go? I would like the differences to be most visible - beetwen spring boot and old spring, so declaring beans in xml would be fine (as in SpringBoot I have annotation like @Service, @Repository etc) -  but it’s hard to explain in my Engineer's Thesis why I’ve chosen for example declaring beans in xml when I could do it easily with annotations.

Do you have any simple crud examples of projects written in these versions?
 
Saloon Keeper
Posts: 12251
259
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

must Janik wrote:Hi, I’m going to start writing my application for athletes based on Spring 2.5.6 and Java 6 (as I’ve read that Java 7 is less compatibile with this Spring version).


You might want to use Java 7 anyway. I think that it might be difficult to find an older Java version from a trusted source for free, and there haven't been huge differences between Java 6 and Java 7. You can get a Java 7 JDK from OpenJDK.

I know already I need web.xml, but do I need servlets  to handle http requests or there is some other common way to do it?


You always need servlets for web applications in Java, unless you're going to write your own HTTP server. Spring requires servlets at any rate. Servlets are used to route the requests to Spring's request pipeline. And web.xml without servlets is pretty pointless because the whole point of web.xml is to configure applications that will run inside a servlet container.

What about declaring beans in these versions. Do I need to do it in xml like <bean>….</bean> or I can annotate class with for example @Component (as @Service propably does not exist in this version). Which way should I go?


The best way to find out all of this is to read through Spring's reference manual. It appears that Spring 2.5.6 already has some stereotype annotations though.

it’s hard to explain in my Engineer's Thesis why I’ve chosen for example declaring beans in xml when I could do it easily with annotations.


Agreed. You should use all the features that your chosen version has to offer, and not use them selectively just to make the difference look bigger.
 
must Janik
Ranch Hand
Posts: 113
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot @Stephan! I think I know already everything that I wanted to know.
 
Saloon Keeper
Posts: 22480
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:
You always need servlets for web applications in Java, unless you're going to write your own HTTP server. Spring requires servlets at any rate. Servlets are used to route the requests to Spring's request pipeline. And web.xml without servlets is pretty pointless because the whole point of web.xml is to configure applications that will run inside a servlet container.



That's not really true. Spring is a very broad framework and you can very definitely write Spring applications without using Spring Web. I use Spring extensively in JavaServer Faces-based webapps. The only mandatory servlet in a JSF webapp is the FacesServlet, which is not part of Spring in any way. I could say the same about Struts, which also has its own dispatcher servlet.

In a technical sense, you're always going to have at least one Servlet, because even if you write the app using nothing but JSPs, JSPs are compiled to produce servlets. People somethings try to produce systems that are nothing but JSPs, but for the most part, they're horrible and riddled with scriptlets

In practical terms, just about all JEE web frameworks have at least one servlet in them, but it's not actually part of the spec or anything. And I suppose you could create an SPA webapp using just a backing JSP and something like React/JS.

 
Stephan van Hulst
Saloon Keeper
Posts: 12251
259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, yes Tim is correct.

What I meant to say is that Spring MVC requires a servlet, and even if you don't use Spring MVC, in practical terms you will always need a servlet anyway.
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
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