Related
I need to port a legacy internal Java EE application (JSPs, EJBs/stored procedures, Weblogic) over to a newer Java web framework and revamp the features/UI substantially. I'm somewhat limited because the backend will remain Oracle Stored Procedures (no direct SQL), so that rules out many ORM/JPA technologies.
At this point, I'm leaning towards using Spring JDBC to wrap the stored procedure access and a combination of Spring MVC, REST & perhaps Twitter Bootstrap for the frontend. Overall, I'd like to be better positioned to support iterative/agile feature development, etc.
Any other (Java) web technologies worth looking into?
This is just my humble opinion, I would recommend looking into Grails. Although it sounds like you won't be able to leverage GORM, Grails still provides an excellent MVC framework approach, and the convention-over-configuration means that you do not need to deal with the XML configuration files and/or annotations that you do with many other frameworks.
Here is another Stackoverflow post regarding Grails without Gorm: https://stackoverflow.com/a/4600991/463196
In Grails, Taglib support is great (writing custom Taglibs has never been easier) and the plugin ecosystem is incredible.
Also, Groovy means not having to write a lot of the boilerplate getter/setters, overloaded constructors of old. The easiest line of code to support is the one that was never written.
I know this is not really an answer to your question since you've given it already. But from personal experience on similar setups (Java EE/Oracle stored procs/functions) I cannot recommend enough the combo you've suggested with Spring Core/MVC and SimpleJdbcCall to link to your existing Oracle stored procs. I particularly like this setup since it scales very nicely and you can start refactoring bit-by-bit non-intrusively.
Ok, I know this is a vague question, and I expect a vague/basic answer.
I am well versed with PHP driven MVC frameworks and how the process of serving pages works. I'm very interested in learning Java, and I figure the only way to learn it is to do it. However, after reading page after page after page, it gets more confusing as I read.
I'm running into GWT (front end), Hibernate (ORM connection?), Spring Architecture, Spring Roo (what is this?), JBoss (servelet), JPA (ORM), POJO (a style of using regular java objects with orm?), Maven?
My basic question is how do all of these fit together? I like the idea of using a framework, because it's worked well in the past with PHP. How do I use this functionality with java? Suppose I wanted to build a web application with a relational data store. How does java authenticate, initate a session, and serve pages with dynamic content? What is the process?
When responding, please don't say "stick with what you know," (as I've seen on other pages) because I'm very interested about java and I'm trying to learn.
I totally hear you - too many acronymns have propped up as Java EE has evolved.
I will try to put an explanation
Java is the language
Java EE (Java Enterprise Edition) is the general term used to encapsulate all Java technologies that help create an enterprise/web application with Java
So a typical web application with Java looks like follows:
Front End
Use JSP or JSF for server side processing and rendering (JSP and JSF
offer ability to define your UI using HTML and server side tags that
bind easily with your Java Beans) However they do tend to mix UI with
backend if not implemented correctly
you can also use plain HTML and any client side toolkits for rendering (such as jquery, dojo, extjs or flex) and fetch your data
from the Java EE server.
you can even mix the two (use a client side framework in a JSP to achieve best of both) or use a toolkit like GWT that offers client side richness with javascript with Java APIs and ease of accessing your java beans
Middle tier
Java Servlets offer the base for all server side processing with Java EE (Servlets offer session persistence, HTTP request processing, response processing) and typically offload the business processing to a model bean - which could be a POJO or spring bean.
Servlets are Java programs you write and are executed in what is called a Java EE container. Popular containers are tomcat, IBM websphere, BEA Weblogic
To help implement a good MVC architecture, there are several frameworks and tools provided on top of Servlets:
Struts2 and Spring MVC are examples of such frameworks
To make it easy to implement web services, Restlet/Jersey help with REST based web services, JAX-WS/APache Axis help with SOAP based web services
Integration with backend database/persistent store
You could use JDBC in your POJO or other model bean to access the DB using Java.
Or alternately use one of the frameworks such as Hibernate to make it easy to interface with the DB backend
Sun's petstore application is a good place to start to learn how the pieces fit together
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eedocs-419425.html#7522-petstore-1.1.2-oth-JPR
Build and Deployment
Ant and Maven are tools used to build your app and manage dependencies
the application gets packaged as a WAR or EAR file and can be dropped into any Java EE container to deploy it. Once it is deployed, it can be accessed using a URL
Tools like Eclipse, Netbeans, Oracle JDeveloper offer integrated IDEs to help with local deployment and testing
The good part with Java EE is that you can pick and choose the components you want to use to build your webapp.
The problem Java has is that it's fairly old and there are TONS of frameworks and packages that do similar things as other packages. At the very core, however, is the Servlet, that specifies how Java behaves as a server over the HTTP protocol.
With that basic building block, there are lots of web frameworks like Struts, and Spring MVC that build up layers of functionality by using lots of good OO development patterns, like Fiters, Delegates, Factories, MVC, etc., to allow the developer to put together an application that takes web requests as input and returns a web response as output.
Those frameworks often build on other frameworks or packages to give application developers more capabilities at different layers of the application. This includes things like ORMs (like Hibernate) to talk to relational databases, or view compositing frameworks like Tiles or Velocity to help put together an HTML page as part of the response.
There are lots of other acronyms and tools and layers that get built up around web frameworks, but essentially they are all just programming tools that have useful functionality pre-built and just need to be used.
If you are looking for a more packaged web application development framework that is more cohesive and doesn't make you feel quite as lost, you may want to take a look at Grails. It is in Groovy, but it is very close to Java in terms of the language and actually builds on top of lots of the other tools you have heard of.
Grails itself builds on the Spring and Spring MVC frameworks, as well as Hibernate, so it's using the same technologies as other more pure Java frameworks, but it abstracts the ugly details away so you don't have to worry about them unless you want to. You can then bundle in additional functionality, like authentication / security, through plugins. If you are well versed in PHP-based MVC frameworks and how they work from an architecture standpoint, you will feel right at home in a similar MVC environment like Grails or Spring MVC. The Grails User Guide is a great place to start, and the rest of the documentation is good too.
If you are new to the Java language, I would strongly suggest doing a few small applications (not web apps, just simple ones) to learn the language and get familiar with how things work. Java is very different from PHP, since PHP bundles in a lot of the base functionality into the language whereas Java has a fairly sparse language with much of the commonly used functionality coming from libraries.
Once you have a good grasp of the Java language, I would jump right to the Grails framework and I would skip all of the nitty-gritty details of servlets and ORMs and Hibernate, etc. at first because you don't need to know it all and there is so much there that it can get in the way of actually understanding things.
Then, once as you start to build out an application with Grails, you will gradually get a deeper understanding of the technology Grails is built on in order to do more complex and powerful things. Slowly, you will work your way into Spring and Hibernate and build up an understanding of how things are put together under the covers, but you can be doing real things faster since you don't have to know all of that from the beginning and can quickly make web applications in Grails the just work, especially with an understanding of the MVC architecture pattern with respect to an application responding to a web request.
Wow, not only is this an open ended question, but it could have pages and pages of answers. I worked in php ~ 7 years ago without a framework so I'll try to point you in some starting directions and compare my experience (which is outdated and sans framework!)
You need an application server just like your Apache server for your Java web app, such as Tomcat, Jboss or Glassfish. These servers handle serving dynamic content.
On top of the server you have your web frameworks which you've mentioned GWT, Spring, and Spring Roo. Spring Roo is like Rails, but in Java. GWT goes all out and and will write your html/javascript code based on your Java code.
In Spring You can define objects to be used in your forms and then when they are submitted the entire object is passed back so there is less work. I remember the days of getting a lot of $_POST[] stuff and I'm thankful not to have to do that when using spring. There is Spring Security that you can use for auth.
The web frameworks are configured to connect to the database and then there is the database abstraction ORM, Hibernate. In PHP I used EZSQL for abstraction which didn't contain nearly the amount of features Hibernate does. Hibernate has a steep learning curve, but is worth learning.
For dynamic GUI's you'll probably want to research JSP, but may be interested in learning JSF.
If I were you, I'd pick an application server, maybe tomcat, then a web framework to play around with, personally I'd go with Spring. The framework will probably have dynamic GUI examples so you'll pick up jsp/jsf. Then possibly add the ORM and a build tool to build externally from your IDE, such as Maven, Ant, or Gradle.
There are some very mature java libraries that each target a very small need in a web application. This means that many tutorials on the subject will have to pick and choose the libraries for each need. For someone just starting out from your position, this probably sucks.
Naively, then, I searched for "java full stack framework" and found: Full stack framework for Java
The benefit of a full stack framework is that you don't have to choose each component. The framework has strong (perhaps rigid) opinions on how ORM is done, how templating is done, how mapping URLs to functions or actions is done, etc.
As for your list of technologies and acronyms:
GWT - a framework from google that focuses on the front end. Poorly stated, write your front end functionality in Java and have it magically transform into javascript.
Hibernate (ORM connection?) - yep, store and load objects in your app.
Spring Architecture - Spring is pretty close to a full-stack framework, but it doesn't have as many rigid opinions on things. You can swap out templating engines, swap out ORM, etc. Not a bad framework, though. You might want to simply follow a tutorial on Spring (see below on Roo), and use the components suggested by the tutorial. Just know that you might find something else later that fills a particular niche.
Spring Roo (what is this?) - Spring Roo takes Spring and becomes opinionated (use what we say). This allows for less code on your part because it provides the code that integrates the various components. It still allows quite a bit of flexibility when you want to change something. Bonus, it comes with a nice tutorial.
JBoss (servelet) - Usually I think of JBoss as an application container. Since the Java EE spec is a bit more complicated than simple CGI--there's a lot of things that need to be set up by the web server (loading classes, loading configuration files, connecting crap together)--JBoss does that stuff. Alternatives are Tomcat or Jetty.
JPA (ORM) - Yeah, it's a common set of interfaces that the various serialization providers might implement. It might be a database, it might be something else. But the idea is that your code for storing and retrieving objects would look the same.
POJO (a style of using regular java objects with orm?) - In context, probably. "Plain Old Java Objects" are nice for any library. Sometimes a framework might require that you inherit your classes from some special class, like Model or Controller to work properly (also, HTTPServlet). This isn't good, because it restricts your own class hierarchy design and makes your own code less flexible. Consequently, things that work with POJOs are considered better.
Maven - Maven is a tool that helps manage dependencies. Without it, java has its own form of DLL hell. Library A depends on version 1.1 of Library B, but Library C depends on version 1.5 of Library B. Ohhh crap, time to read through a tutorial on classloaders. Don't worry too much, though, any tutorial on java web apps is likely to tell you exactly what you need to download and use.
The first thing I would suggest you to start with, given a knowledge of http protocol, is the JSP technology. Although you would probably use some framework like JSF2 for instance, it is important to start with JSP in order to well understand the technology and how to use it to deal with request/responses (that's my humble opinion of course).
Once you are familiar with JSP and, let's say, JSF 2.0 (you can find loads of documents on that topic) the next step is to try to connect with a data source. In Java EE technology there is a specification called JPA (Java Persistence API). JPA is just a specification for ORM (which is, roughly speaking, mapping an object java model with a set of DB tables)
Once you have your web application working with some basic pages and some operations on a DB you could enforce the security of your app introducing some security mechanisms.
this is a very good reference and start point for all of these topics and much more. It's a long path and it will take you some time. But, believe me, it's worth it!
Good luck!
I suggest you google those keywords and look for some books and tutorials.
Maven
is a tool for managing your Java projects and artifacts (JARs, WARs, etc.). I'd start learning Maven first, so that you have a foundation to create your Java projects on. It also handles your dependency management: you just specify what JARs you need in your application and Maven will download them for you.
JPA (Java Persistence API) handles the Object-Relational-Mapping of your entities. You can write POJOs (plain old Java objects) and map them to your database tables.
Hibernate is a JPA provider (i.e. implementation of JPA). Usually you don't have to deal with Hibernate that much, most of the time you can use JPA directly. You just configure the JPA provider in the persistence.xml config file.
CDI (Context and Dependency Injection) see description. CDI "wires" the components of your application together.
Springframework started as a framework to offer Dependency Injection capabilities, but today it's much more than that. The WebMVC module of spring might be interesting to you. You can write Controllers and Views (using JSP for example).
Servlet API A servlet acts like a little server, handling a HTTP request and generating the response. You can write your own servlets or use a web framework to do it's job, for example Spring's DispatcherServlet or Java Server Faces, or whatever framework.
JSP is a technology to write templates for your HTML files. JSP files are being compiled into Java classes and can contain HTML code, JSP-specific XML code and Java code.
Example:
<ul>
<c:forEach items="${countries}" var="country">
<li>${country}</li>
</c:forEach>
</ul>
renders a list of countries, where ${countries} might be a collection of country objects (or strings in this case).
JSF (Java Server Faces) is another framework for building web applications, utilizing JSP and/or XHTML for defining the views and backing beans for the backend part. I would start learning with JSP instead of JSF, it's easier to learn.
Most of the frameworks are part of the JavaEE standards portfolio. For stuff like CDI to work you need either an application server (like JBoss AS) or at least a server with a servlet container (like Apache Tomcat or Jetty) in combination with Spring.
Spring and Hibernate are not standard, but they implement many of the standard APIs nowadays.
**EDIT: ** you might also want to learn about Annotations in Java code. They are around since Java 5 and are widely used as an alternative to XML based configuration.
So my suggestion is that you start learning Maven (not necessary tho, you can also manage your project manually), then Spring and JSP to be able to create a simple web application and then JPA/Hibernate to make your data persistent.
In my opinion learning Spring is much easier than learning the whole JavaEE APIs, since Spring is quite good documented.
One of the nice things about GWT is that you'll right your client code in Java, with all of its benefits and if you have server code, that could also be in Java as well, and you could share some of the source code, even if the front-end ends up running as JavaScript.
TO build a basic Java web application, go through this tutorial as it will explain the core foundational technologies with the standard Java EE platform and how to develop something real with them.
http://netbeans.org/kb/docs/javaee/ecommerce/intro.html
It will demonstrate the standard Java web technologies such as EJBs, Servlets, JSP, JPA, and how to use Netbeans for your IDE.
Most beginner's are very overwhelmed by the thousands of different technologies and platforms out there with the Java EE framework. Java caters to a very 'open source' type of community and that means that you have ALOT of different choices and road maps on how you can build applications. This is very different from say the .NET world where everything is pretty straightforward and there's a very clean cookie cutter path.
Once you have learned these foundational basics by going through the tutorial, you will have a grasp on what the Java EE framework. Once you understand these basics, you can then start to learn about Maven or Spring and how those type of technologies can help you build better applications and you can make better and more educated decisions.
GWT - Web interface tools. Some competing technologies: Spring, JSF, Wicket
Hibernate - ORM mapping for databases. Competing technology: JPA
Spring Architecture - Web Framework. Competing technology: JSF, Wicket, GWT
Spring Roo - An MVC style flavor of Spring.
JBoss - Application hosting. Competing technologies: Glassfish, Tomcat
JPA - ORM mapping for databases. Competing technology: Hibernate
POJO - Plain old java object. Just a simple object.
Maven - Maven is a way to manage libraries or dependencies that your project uses. There's a central server that hosts many of these libraries and if you ever need to import a new one to use in your project, it's as simple as searching through the server and then copy and paste the configuration settings that they provide you into an XML document called the POM file or pom.xml
Vijay's answer above is pretty much spot on. I'll elaborate on a few points.
Most of the "fameworks" that you mention, spring, roo (which is just a way to work with spring), gwt, struts, etc. all work on top of "Java EE". Java EE is Sun (now oracle's) term for the "standard" way to work with web applications. Java EE also includes a lot of more enterprise stuff like EJBs, JMS, JMX which you won't really need to concern yourself with unless you're doing very high end stuff.
JSP is the part that will be most familiar to you coming from PHP, it's a way of embedding code inside of an HTML page.
Servlets are the middle tier, that's where database connections are created and application logic happens. As it turns out, JSPs are converted into Servlets at compile time.
All Java EE stuff runs inside of a "servlet container" or an "application server". That's the big difference between java and php. Your choices here are usually Tomcat, JBoss or Jetty.
Maven is a build system that helps you to manage 3rd party jar files (libraries) and compiles and runs your test codes. It has plugins to deploy your code to tomcat/jboss/jetty.
POJO stands for "Plain old java object". Most modern frameworks try to shield you from the complexities of what happens under the hood and let you work with "POJOS". This comes into play when working with something like spring or hibernate. You may also see the term "java bean" tossed around, that's a standard way of defining "pojos" that just sets up a convention about how to name getter/setter methods and constructors.
I would recommend getting a book on getting started with JSPs/Servlets and starting there.
I have just started learning java and i have about 8 months time. My main aim is to build web application using java. But as there are many java technologies/frameworks available i am conufused how should i go
IDE i am using is eclipse
The path which i am thinking is below
1)Learn Core Java
2)Project: Build Java Invoicing System with JDBC or mysql to test java knowledge
3)Learn Servlets / JSP to
4)Build small site like simple logon/memberarea/catalogue using servlets/jsp
Now guys I really don't know where the following things stand in my path and which things they will help
1)Java EE
2)Spring or spring MVC, what's the difference?
3)Hibernate
4)Wicket
5)Struts
I really don't know how should i learn those and which things to choose from.
what should be my final project which can be build using those because if i see from my current stage even website can be build using servlets/jsp. then why do i need those other technologies
Can anyone give an example of a project which can be build using new technologies and not using jsp/servlet, so that I can get an idea why we need those?
Lot's of stuff to learn in here so I would take it a bit at a time. I'm going to assume you are relatively comfortable with the Java language and core APIs.
First learn about JDBC and databases. Get a basic functional JDBC example app working (not visual just some a vanilla Java app) that does read/insert/update/delete of some records in a table. This will give you the basis for building whatever app you choose. Almost all interesting applications involve some sort of persistence/database.
Learn the main JDBC APIs (Connection, PreparedStatement, ResultSet) and write some code that uses these to get comfortable.
Learn about how transactions work in databases if you aren't familiar already and how JDBC uses them (Connection.commit and rollback)
Next you could look into the spring framework. This has a several useful features that come in handy when building these applications. The main ones to get to know the dependency injection functionality and the JDBC libraries it has. The DI stuff is a bit of a "duh"? if you haven't used it before but it is very useful/powerful especially for medium size + apps. The JDBC libraries help with the cruft of dealing with the raw JDBC APIs and make your code less error-prone.
Once you've got some basic JDBC and Spring stuff worked out you can then start bringing in a web framework.
This is more difficult because there are so many. In the interest of getting something up and running quickly I would probably go with Wicket. It runs inside a servlet container like Jetty, easy to get up and running with a basic web page or two and relatively easy to evolve of the project over time without going down too many blind alleys. I've found that frameworks like JSF (the Java EE default web/view framework) takes a lot of up front time investment to get going on. Most of these frameworks, including Wicket, can leverage the spring stuff you've got above.
Avoid JSP, it's unpleasent technology and outdated by virtually everything else.
To answer some of your other points.
Hibernate is a tool for mapping an object model to a relational model. In it's most basic form you define a Java class for each DB table with the class having one Java property (variable+getter+setter) for each DB column. You can also add references from one class to another to model database relations. It is good but it takes a bit of getting used to.
Spring I've explained partly above. Spring is much bigger than just DI and some JDBC libraries. It also has transaction management libs and bunch of other stuff. Spring MVC is a web framework which lives under the spring umbrella and makes use of a lot of the spring libraries internally. I've never used it so can't offer an opinion on it.
Java EE is an umbrella term for a large set of "enterprise" specifications/libraries. JSF is a web view framework that is part of Java EE.
That's my very high level advice. To summarise I would learn basic DB/JDBC then some spring stuff and then start building a basic web app using what you've learned already.
Hope that helps. There's plenty of info out there on the web on all these topics and you can always ask questions here on more specific parts if you need help. Good luck and enjoy!
EDIT (to address comment):
All of the above is my recommendation/opinion on how to approach learning Java web development.
In summary
Learning JDBC/transactions/databases is a must
Spring is optional but I strongly recommend. Spring is a big library but you can pick and choose the bits you like/need.
Web frameworks the choice is really yours. From what I have tried (JSF/JSP/Wicket) Wicket is the easiest to get going with so you don't spend too much time frustrated with the getting the initial setup. JSP is awful, it's very easy to make a mess with it. JSF is powerful but heavy and probably more suited to very enterprisy projects than a first web app.
Hibernate is optional but can make life easier simply because you can work with Java objects when you do DB queries/updates rather than writing tedious insert/update statements. Hibernate isn't the only tool like this but it's the one I've used most and does the job well. Just don't go too overboard with the "clever" hibernate features initially.
You could easily use Spring MVC instead of Wicket. That may be a perfectly good choice, I've not used Spring MVC myself so can't comment. I'm sure it will integrate well with spring stuff tho so that would certainly be a positive factor.
Do some more research if you're not sure, there's no end of people happy to give their opinion! But really you just have to dive in and try something.
You are correct. If all your applications are served by servlets, JSPs, and JDBC, then maybe you don't need to learn anything else.
I commend you for learning the fundamentals first before diving into a thicket of frameworks that you don't understand. That's a good thing.
But if you reach the point where you have those down cold, maybe looking at these other technologies can help you improve your game.
1)Java EE
You are learning (part) of Java EE when you use servlets, JSPs, and JDBC. They're a subset of the full Java EE machinery - EJBs, JMS, JNDI, etc.
2)Spring or spring MVC whats
difference
Spring is an alternative framework developed by Rod Johnson and Springsource, now part of VMWare, that is based on dependency injection, aspect-oriented programming, and framework modules. Spring web MVC is one module in the Spring framework, based on servlets, that acts as the front end for web applications.
3)Hibernate
An object-relational mapping technology (ORM), built on top of SQL and JDBC, that lets you map objects to tables. It has its own object-based query language.
4)Wicket
Another web MVC alternative to Spring MVC, Struts, JSF, etc.
5)Struts
The first web MVC framework. It's gone through versions 1.0 and 2.0, and has now been supplated by Java Server Faces. It's still used, though. Like all other web MVC frameworks in Java, it's based on servlets and JSPs.
From a Java perspective it might be best to start looking at Java EE. All the others you mentioned are alternative technologies, which might be useful to you if you decide that what the standard framework offers isn't your cup of tea. But for that to decide, it's never a bad idea to at least know what the standard framework is about.
Truth be told, before 2006 the standard framework had a bad reputation and some of the sentiments that form the basis for recommending alternative technologies are still based on that. Starting with version 5, Java EE got dramatically better. The latest version, Java EE 6 is arguably one of the best Java frameworks that's out there. Of course, the best is a highly subjective term and naturally it won't be the best one for each and every person out there.
At any length, Java EE 6 is a very complete framework that allows a large range of application to be written without depending on any additional library. Being the standard framework, most other frameworks at least depend on some parts of it.
Most typically EJB, CDI and JSF are replaced by alternative technologies. E.g. the core Spring container replaces EJB and CDI and Spring MVC replaces JSF. A full Spring stack typically still uses JPA, JTA, JMS and Servlet from Java EE. Wicket on its turn only replaces JSF, or when used with a Spring stack replaces Spring MVC.
Hibernate is a special case. It doesn't replace anything from Java EE, but is instead often used as an implementation for one of the key APIs of Java EE: JPA. The original creator of Hibernate, Gavin King, is one of the prime supporters of the Java EE framework and is in fact the spec lead of one of the most important parts of modern Java EE: CDI.
Wicket by itself is a very nice web framework, but in practice it isn't used as often as JSF. I won't go into the discussion whether Wicket or JSF is 'better' (this is mostly a religious battle anyway), but due to the popularity of JSF there are simply more people experienced with it and there is a large community offering many things for JSF like component libraries and extensions.
Struts has historically been completely replaced by JSF. The original creator or Struts, Craig Mcclanahan, was the one who started JSF as the successor of Struts. Nevertheless, Struts was once the absolute de-facto standard for web frameworks in Java. It's not often advised to be used for new projects, but till this day it's still used in a huge number of existing applications. So even though it's not really 'hot' to learn Struts anno 2011 knowledge of it may still be very practical for when you have to maintain existing applications.
ps
See this answer for a general description about Java EE: Frameworks for Layering reusable Architectures
I'm sure that nobody seriously can tell you the best way, because this would mean that (s)he would have tried all. Why do you want to learn a Java web application framework? Just to learn it to be prepared for the (next) job? In that case it is likely that you've learned the wrong one.
The next question would be what you want to do with the web application framework. Do you want to make a website a little bit active, e.g. make each page look similar (corporate design), auto-generate menus from an internal structure, or do you want to write a real web application, e.g. with database access.
I'd first define the goal what you want to achieve. IMHO a good way to motivate you to make it right is to take a small project which helps you to solve a small problem.
Then I would start with Java Server Pages (JSP) and servlets to understand the basic concepts. Then you can try to do the same with a few well-known web application frameworks, e.g. Wicket.
Sorry for asking this question, but I searched all Java-related questions, but I got more confused. I am still not clear what should I start with.
My main thing is building websites in Java, because someone told me that there are some machine learning or AI libraries available in Java which I can use in Java. So I decided to use that as it can reduce my work.
Now I don't know Java at all. Some people say the following are used to build websites, like:
Servlets alone can build a website
JSP alone can also build a website
Struts
Spring Framework with Hibernate
Seam
Java EE also for websites
I am confused. Where should I start from? Where does core Java fits in here?
I was thinking of perhaps learning Python as I know I have to learn Python only, not its variations.
So please guide me to one thing which can solve my basic purpose of using ready-made libraries of AI.
If I can do that with JSP then I will start with that.
But if I need to learn all of them, then it’s better if can start learning Python.
I have five months to finish the website.
I really don't know why there are many branches of Java for doing one thing.
To correct some misconceptions of yours:
servlets and JSP are Java EE
Seam and Struts can be used together with Hibernate as well
Spring MVC is a web framework. Spring as a dependency injection framework can be used together with any other framework.
there are many more options, like JSF, Tapestry, Click, Play, etc.
It depends on what will the site will be doing, but you can choose any.
Experience has shown that building complex HTML forms (especially validation) and Ajax functionality is hard to get right. You will most likely appreciate having a library to assist you with that. The same thing with database access.
Everything builds on servlets. Learn those in order to understand the libraries you will use.
I would suggest learning JavaServer Faces (JSF) with facelets. The easiest, while being powerful, is JSF 2 in Java EE 6. The easiest way to get started is to use NetBeans with GlassFish 3.
For static web pages, HTML alone is enough and if you want to make it more user-friendly and interactive, use JavaScript.
There are lot of frameworks you can use directly in JavaScript, like jQuery. Now if you want to make some more functionalities, like database interaction, then you will need either PHP, Java (JSP and Servlets) or .NET (there exist some more, but I’m aware of three only). Each of them have their library to interact with database.
Since you are interested in Java, go through Servlets, HTML, JavaScript, and JSP. Once this is done, you can look into JSF and EJB beans. So if you have knowledge of Java this will not take too much time, because the syntax is the same; the only difference is the concept.
So you will have a frontend (HTML, JS, and JSP) which will interact with the backend (Servlets and the database) which will be deployed in a Web container. To deploy, you can use an one of the available application servers, like Apache Tomcat, GlassFish, or WebSphere. To develop your application, you can use Eclipse as the IDE, which is one of the best IDEs I have used.
So decide your architecture and design, break it into components and start writing small applications first. Once you are experienced in small application, start writing an application where there are more things you have to care of, like load on database, availability, security, etc. For that, you can refer a very famous question on Stack Overflow, What technical details should a programmer of a web application consider before making the site public?.
The closest to core Java is servlets. No extra syntax, very minimal library, but no included functionality.
For building websites, the main thing is HTML and HTTP.
All technologies (including Enterprise Java or Server side Java) do the same—to understand an HTTP request and respond back with HTML. All that you mentioned do the same thing with a different level of sophistication.
Start with Wikipedia.org to know what technologies do what. If you are completely new to Java, go through the Sun tutorials, do sample programs, and get comfortable with Java packages, JVM and classes. (This might take a week or two).
To build websites using Java, you'll have to learn Java Servlets—everything else (JSP, Struts, JSF, and Spring(!)) are built on it. Get Head First books on Java and Servlets; they will be useful.
You can always build the page in Ruby or something that will give you a website very fast. For the AI stuff that analyzes the bought items for the recommendations, use something unrelated to the page that only takes the database to work with.
I would not mix the whole web page stuff with the AI computing. You can do the AI things that will take a long time and maybe should done on a different machine to have your webpage also responsive with C++ or Java in normal applications.
Choosing your front end technique because of later usage is a very dangerous thing. Using the whole Java EE concept and learning it from scratch will take you much longer than have a quick start with your page if you do it in Ruby or PHP.
You can then build the first version of the page and generate a user base. Start working on the AI stuff once you got some data with other technologies.
If your page has performance problems because your technology does not scale, you can always begin switching parts of the stuff out with a faster technology or maybe simply a bigger machine. Get your page running before you build it bulletproof for the thousand users you are expecting.
If you’re trying to build a website from scratch, with no prior knowledge, your best bet is to go with frameworks that provide a complete stack for web development.
If you aren't dead set on Java, you could probably start learning Ruby on Rails, which would be easier to start with (if so, go buy a Ruby on Rails tutorial which goes through all the necessary things for modern web development, from MVC to version control).
For Java, try:
Play Framework is very similar to Ruby on Rails. It will get you started very quickly, and hopefully (if you follow conventions) handle all of your peripheral needs.
Spring Roo is a very-fast-to-work-with framework, but it might get hard to maintain and extend later on.
These two are full web frameworks, that is, they handle database, MVC (presentation layer), configuration setting, etc... (I'll explain shortly). And could even ease your deployment process.
If you're going to go through any other route (using several frameworks together), you are probably not going to finish what you are doing in five months.
To understand why, and to clear some things you wrote in your question, you need to understand that modern web development (and enterprise development as a whole) is comprised of several different technologies:
Presentation: the term web frameworks has been more or less taken to mean frameworks that deal with this side of web development, i.e., how to create a web page (an HTML page). Most of the frameworks offer an MVC like approach (which you can read about elsewhere), and this is what most of the frameworks/technologies you gave sit in—JSP and Struts (which uses JSP) are examples of web frameworks. Servlets is a lower-level API that standardizes how to answer HTTP requests (which JSP and Struts sit on top of).
Persistence: being able to show a webpage doesn't mean squat these days if you can't save data to a database, and that is what the persistence frameworks do (they ease the way you can save data to the database). Hibernate is a persistence framework.
For Java there are also dependency injection (DI), which is what Spring DI is. It's tough to explain DI to people not familiar with the troubles of Java, so I won't try to explain it, but it's a very important part of modern Java development.
apart from these core technologies, there are also many items that you'll need to learn to actually deploy the application (unless your using services like Heroku or Google App Engine, which should simplify things), and troubleshoot it later (understanding how concurrency and HTTP works).
To address the other technologies you brought up:
I've never really touched Seam, so I'm not sure, but it looks like a collection of other frameworks (mainly EJB 3, which itself is a collection of APIs, and JSF).
Spring denotes a popular open source group (the SpringSource group) that provides various technologies, but most likely when you hear about it they refer to two things Spring's dependency injection (DI) and Spring's MVC (which is a web framework).
Java EE is merely a collection of high level APIs which other technologies implement (Hibernate implements JPA which is part of Java EE for instance).
I am a reasonably competent programmer, with about 11 years experience.
I particularly like Ruby/Rails and ActionScript.
And Java is easy enough, I've used it for ordinary applications, and mostly as ones that run on the server, just not web-based ones.
I'd like to develop a web application in Java in order to leverage things like BlazeDS and help tie front-ends together with my previously-written Java apps. i.e. use existing Java code but in a web context.
But I'm having trouble - and confused - looking for a smooth start. I don't want to use Grails, been there, thanks, I want to use Pure Java, with whatever Framework you can think of. Spring, Hibernate, etc.
Where do I start?
Play Framework lets you get started quickly. http://www.playframework.org/
Spring Roo is a RAD framework for web apps. It's similar to like Rails or Grails, but uses code generation instead of metaprogramming magic.
This thread contains useful pointers on starting Java web development
http://www.daniweb.com/forums/thread249070.html
Since your goal is "Pure Java," how about Wicket? Straight from their feature list:
Wicket does not mix markup with Java code and adds no special syntax to your markup files. The worlds of HTML and Java are parallel and associated only by Wicket ids, which are attributes in HTML and Component properties in Java. Since Wicket HTML is just HTML and Wicket Java is just Java, coders and designers can work independently to a large degree and without relying on any special tools.
If you want more info, there's a web page on why you should use Wicket.
I've really enjoyed working with Spring MVC. It took a while to ramp up with Spring, but the whole affair has just made since after investing the time.
I have found JavaServer Faces 2.0 using Facelets to be a good compromise between power and ease of use, plus it allows you to use a lot of extra libraries when you get more advanced.
For JBoss you need to include JSF in your web application. Download the 2.0.2 distribution and see the documentation in there.